/** * @depends testFetch */ public function testGetResource() { $this->imgManMock = $this->getMockBuilder('ImgMan\\Service\\ImageService')->disableOriginalConstructor()->getMock(); $resource = new ImgManConnectedResource($this->imgManMock); $this->assertNull($resource->getResource()); $this->imgManMock = $this->getMockBuilder('ImgMan\\Service\\ImageService')->disableOriginalConstructor()->setMethods(['has', 'get', 'getSrc'])->getMock(); $this->imgManMock->expects($this->any())->method('has')->with($this->equalTo('testId'), $this->equalTo(CoreInterface::RENDITION_ORIGINAL))->will($this->returnValue(true)); $this->imgManMock->expects($this->any())->method('getSrc')->with($this->equalTo('testId'), $this->equalTo(CoreInterface::RENDITION_ORIGINAL))->will($this->returnValue(null)); $this->imgManMock->expects($this->any())->method('get')->with($this->equalTo('testId'))->will($this->returnValue($this->getMock('ImgManTest\\Apigility\\Asset\\TestImage'))); $resource = new ImgManConnectedResource($this->imgManMock); $event = new ResourceEvent(); $event->setTarget(new Resource()); $event->setName('fetch'); $event->setParam('id', 'testId'); $event->setRequest(new Request()); $resource->setEntityClass('ImgManTest\\Apigility\\Asset\\TestImage'); $resource->dispatch($event); $this->assertInstanceOf('ZF\\Rest\\ResourceInterface', $resource->getResource()); }