public function testGetSizesCacheHit() { $this->cache->expects($this->once())->method('getItem')->with(1234)->will($this->returnValue(array('Image information'))); $this->service->expects($this->never())->method('getSizes'); $result = $this->serviceCache->getSizes(1234); $this->assertEquals(array('Image information'), $result); }
/** * @covers FA\Service\ImageService::findAll */ public function testFindAll() { $imageData = array(array('day' => '1', 'photo_id' => '11'), array('day' => '2', 'photo_id' => '22'), array('day' => '3', 'photo_id' => '33')); $imageSizes = array(array('sizes' => array(11)), array('sizes' => array(22)), array('sizes' => array(33))); $this->dao->expects($this->once())->method('findAll')->will($this->returnValue($imageData)); $expected = array(); // The Flickr service should be called as many times as there are // data elements returned from the dao foreach ($imageData as $index => $image) { $expected[] = array_merge($image, $imageSizes[$index]); $this->flickr->expects($this->at($index))->method('getSizes')->with($image['photo_id'])->will($this->returnValue($imageSizes[$index])); } $result = $this->service->findAll(); $this->assertEquals($expected, $result); }