Beispiel #1
0
 public function getFirstLink($rel)
 {
     $link = $this->getLinkData($rel);
     if (!isset($link[0])) {
         return null;
     }
     return HalLink::fromArray($this->client, $link[0]);
 }
Beispiel #2
0
 /**
  * @test
  */
 public function it_can_request()
 {
     $httpClient = new RecordingHttpClient();
     $client = new HalClient('http://propilex.herokuapp.com/documents', $httpClient);
     $link = new HalLink($client, '/documents{?page,limit}', true, 'application/hal+json', 'http://example.com/deprecation', 'name', 'http://example.com/profile', 'title', 'en');
     $link->request('PATCH', $this->variables, ['headers' => ['Foo' => 'bar'], 'body' => 'Body', 'query' => 'key1=key2']);
     $lastRequest = $httpClient->getLastRequest();
     $this->assertSame('PATCH', $lastRequest->getMethod());
     $this->assertSame('http://propilex.herokuapp.com/documents?page=1&limit=10&key1=key2', (string) $lastRequest->getUri());
     $this->assertSame('Body', (string) $lastRequest->getBody());
     $this->assertSame(['bar'], $lastRequest->getHeader('Foo'));
 }