public function prepareCallback($collection) { $i = 0; foreach ($collection as $key => $value) { $this->cb->expects($this->at($i++))->method('call')->with($value, $key, $collection); } }