public function testFromLinkShouldUseLinkExtractor() { $link = new Link('foo'); $extraction = true; $linkExtractor = $this->prophesize(LinkExtractor::class); $linkExtractor->extract($link)->willReturn($extraction); $linkCollectionExtractor = $this->prophesize(LinkCollectionExtractor::class); $linkCollectionExtractor->getLinkExtractor()->willReturn($linkExtractor->reveal()); $this->plugin->setLinkCollectionExtractor($linkCollectionExtractor->reveal()); $result = $this->plugin->fromLink($link); $this->assertEquals($extraction, $result); }
public function testFromLinkShouldUseLinkExtractor() { $extraction = true; $linkExtractor = $this->getMockBuilder('ZF\\Hal\\Extractor\\LinkExtractor')->disableOriginalConstructor()->getMock(); $linkExtractor->expects($this->once())->method('extract')->will($this->returnValue($extraction)); $linkCollectionExtractor = $this->getMockBuilder('ZF\\Hal\\Extractor\\LinkCollectionExtractor')->disableOriginalConstructor()->getMock(); $linkCollectionExtractor->expects($this->once())->method('getLinkExtractor')->will($this->returnValue($linkExtractor)); $this->plugin->setLinkCollectionExtractor($linkCollectionExtractor); $link = new Link('foo'); $result = $this->plugin->fromLink($link); $this->assertEquals($extraction, $result); }
public function testFromLinkShouldComposeAnyPropertiesInLink() { $link = Link::factory(array( 'rel' => 'resource', 'url' => 'http://api.example.com/foo?version=2', 'props' => array( 'version' => 2, 'latest' => true, ), )); $result = $this->plugin->fromLink($link); $expected = array( 'href' => 'http://api.example.com/foo?version=2', 'version' => 2, 'latest' => true, ); $this->assertEquals($expected, $result); }