Пример #1
0
 /**
  * @param string $name
  *
  * @return Resource
  */
 public function get($name = null)
 {
     $this->initialize();
     if ($name) {
         return $this->resource->get($name);
     }
     return $this->resource;
 }
Пример #2
0
 public function testRefresh()
 {
     $client = $this->getMock('Ekino\\HalClient\\HttpClient\\HttpClientInterface');
     $client->expects($this->exactly(1))->method('get')->will($this->returnCallback(function ($url) {
         if ($url == 'http://propilex.herokuapp.com') {
             return new HttpResponse(200, array('Content-Type' => 'application/hal+json'), file_get_contents(__DIR__ . '/../fixtures/entry_point.json'));
         }
     }));
     $resource = new Resource($client, array(), array('self' => array('href' => 'http://propilex.herokuapp.com')));
     $this->assertNull($resource->get('field'));
     $resource->refresh();
     $this->assertEquals($resource->get('field'), 'value');
 }
 /**
  * @param null|array $data
  *
  * @return Resource
  */
 protected function createResource($data)
 {
     if (null === $data) {
         return null;
     }
     return Resource::create($this->client, $data);
 }
Пример #4
0
 public function testLinkHref()
 {
     $this->assertEquals('http://localhost/article/42', $this->resource->getLink('article')->getHref(array('id' => 42)));
     $this->assertEquals('http://localhost/tag/{id}', $this->resource->getLink('bar:tag')->getHref(array('id' => 42)));
     $this->assertEquals('http://localhost/media', $this->resource->getLink('test:media')->getHref());
 }