See also: http://stateless.co/hal_specification.html
示例#1
0
文件: LinksTest.php 项目: Joal01/fof
 /**
  * @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);
 }
示例#2
0
文件: Document.php 项目: akeeba/fof
 /**
  * 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);
 }