See also: http://stateless.co/hal_specification.html
Example #1
0
 /**
  * @covers FOF30\Hal\Links::getLinks
  */
 function testGetLinks()
 {
     // Create a sample link
     $newlinks = array('foo' => array(new Link('http://www.example.com/yeah.json', false, 'Something'), new Link('http://www.example.com/another.json', false, 'Something else')), 'bar' => array(new Link('http://www.example.com/foo{?id}.json', true, 'Foo link'), new Link('http://www.example.com/bar{?id}.json', true, 'Bar link')));
     $linkset = new Links();
     $linkset->addLinks('foo', $newlinks['foo']);
     $linkset->addLinks('bar', $newlinks['bar']);
     $links = $linkset->getLinks();
     $this->assertArrayHasKey('foo', $links);
     $this->assertArrayHasKey('bar', $links);
     $this->assertEquals($newlinks['foo'][0], $links['foo'][0]);
     $this->assertEquals($newlinks['foo'][1], $links['foo'][1]);
     $this->assertEquals($newlinks['bar'][0], $links['bar'][0]);
     $this->assertEquals($newlinks['bar'][1], $links['bar'][1]);
     $links = $linkset->getLinks('foo');
     $this->assertEquals($newlinks['foo'][0], $links[0]);
     $this->assertEquals($newlinks['foo'][1], $links[1]);
     $links = $linkset->getLinks('baz');
     $this->assertInternalType('array', $links);
     $this->assertEmpty($links);
 }
Example #2
0
 /**
  * Returns the collection of links of this document
  *
  * @param   string  $rel  The relation of the links to fetch. Skip to get all links.
  *
  * @return  array
  */
 public function getLinks($rel = null)
 {
     return $this->_links->getLinks($rel);
 }