コード例 #1
0
ファイル: HalTest.php プロジェクト: zfcampus/zf-hal
 public function testLinkCreationFromEntity()
 {
     $self = new Link('self');
     $self->setRoute('resource', ['id' => 123]);
     $docs = new Link('describedby');
     $docs->setRoute('docs');
     $entity = new Entity([], 123);
     $entity->getLinks()->add($self)->add($docs);
     $links = $this->plugin->fromResource($entity);
     $this->assertInternalType('array', $links);
     $this->assertArrayHasKey('self', $links, var_export($links, 1));
     $this->assertArrayHasKey('describedby', $links, var_export($links, 1));
     $selfLink = $links['self'];
     $this->assertInternalType('array', $selfLink);
     $this->assertArrayHasKey('href', $selfLink);
     $this->assertEquals('http://localhost.localdomain/resource/123', $selfLink['href']);
     $docsLink = $links['describedby'];
     $this->assertInternalType('array', $docsLink);
     $this->assertArrayHasKey('href', $docsLink);
     $this->assertEquals('http://localhost.localdomain/help', $docsLink['href']);
 }