Ejemplo n.º 1
0
 /**
  * @test
  */
 public function it_can_request()
 {
     $httpClient = new RecordingHttpClient();
     $client = new HalClient('http://propilex.herokuapp.com', $httpClient);
     $resource = new HalResource($client, [], ['self' => ['href' => '/documents']]);
     $resource->request('PATCH', ['headers' => ['Foo' => 'bar'], 'body' => 'Body', 'query' => 'key1=key2']);
     $lastRequest = $httpClient->getLastRequest();
     $this->assertSame('PATCH', $lastRequest->getMethod());
     $this->assertSame('http://propilex.herokuapp.com/documents?key1=key2', (string) $lastRequest->getUri());
     $this->assertSame('Body', (string) $lastRequest->getBody());
     $this->assertSame(['bar'], $lastRequest->getHeader('Foo'));
 }
Ejemplo n.º 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'));
 }