/** * @group 79 */ public function testFactoryCanGenerateLinkWithRouteInformation() { $rel = 'describedby'; $route = 'api/docs'; $params = array('version' => '1.1'); $options = array('query' => 'version=1.1'); $link = Link::factory(array('rel' => $rel, 'route' => array('name' => $route, 'params' => $params, 'options' => $options))); $this->assertInstanceOf('PhlyRestfully\\Link', $link); $this->assertEquals('describedby', $link->getRelation()); $this->assertEquals($route, $link->getRoute()); $this->assertEquals($params, $link->getRouteParams()); $this->assertEquals($options, $link->getRouteOptions()); }
/** * @group 95 */ public function testPassingFalseReuseParamsOptionShouldOmitMatchedParametersInGeneratedLink() { $matches = $this->matchUrl('/resource/foo'); $this->assertEquals('foo', $matches->getParam('id', false)); $link = Link::factory(array('rel' => 'resource', 'route' => array('name' => 'hostname/resource', 'options' => array('reuse_matched_params' => false)))); $result = $this->plugin->fromLink($link); $expected = array('href' => 'http://localhost.localdomain/resource'); $this->assertEquals($expected, $result); }
/** * Inject any links found in the metadata into the resource's link collection * * @param Metadata $metadata * @param LinkCollection $links */ protected function marshalMetadataLinks(Metadata $metadata, LinkCollection $links) { foreach ($metadata->getLinks() as $linkData) { $link = Link::factory($linkData); $links->add($link); } }