Пример #1
0
 public function testCreateInvalidStatusCodeThrowsException()
 {
     $request = new Request();
     $request->setUri('http://test.dev/testapi');
     $request->setMethod(Request::METHOD_POST);
     $request->getHeaders()->addHeaders(array('Accept' => 'application/json'));
     $response = new Response();
     $response->setContent(json_encode(['type' => 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html', 'title' => 'Forbidden', 'status' => 403, 'detail' => 'Forbidden']));
     $httpClient = $this->getMock('Zend\\Http\\Client', array('send'));
     $httpClient->expects($this->once())->method('send')->with($this->equalTo($request))->will($this->returnValue($response));
     $client = new Client($httpClient, 'http://test.dev/', ['Accept' => 'application/json']);
     $client->setThrowExceptions(true);
     $this->expectException('Jolicht\\ApigilityClient\\ClientException');
     $this->expectExceptionCode(403);
     $this->expectExceptionMessage('Forbidden');
     $client->create('/testapi', []);
 }