/**
  * @test
  * @expectedException \Jsor\HalClient\Exception\BadResponseException
  */
 public function it_will_transform_bad_response_exception_without_response()
 {
     $guzzleClient = $this->getMock('GuzzleHttp\\ClientInterface');
     $guzzleClient->expects($this->once())->method('send')->will($this->returnCallback(function ($request) {
         throw new GuzzleBadResponseException('Error', $request);
     }));
     $client = new HalClient('http://propilex.herokuapp.com', new Guzzle6HttpClient($guzzleClient));
     $client->request('GET', '/');
 }
Beispiel #2
0
 /**
  * @test
  * @expectedException \Jsor\HalClient\Exception\BadResponseException
  * @expectedExceptionMessage JSON parse error: Syntax error
  */
 public function it_throws_exception_when_http_client_returns_invalid_json()
 {
     $httpClient = $this->getMock('Jsor\\HalClient\\HttpClient\\HttpClientInterface');
     $httpClient->expects($this->once())->method('send')->will($this->returnValue(new Response(200, ['Content-Type' => 'application/hal+json'], '{')));
     $client = new HalClient('http://propilex.herokuapp.com', $httpClient);
     $client->request('GET', '/');
 }