/**
  * @test
  * @dataProvider getErrorCodesProvider
  * @expectedException \Github\Exception\ValidationFailedException
  */
 public function shouldNotPassWhen422IsSentWithErrorCode($errorCode)
 {
     $content = array('message' => 'Validation Failed', 'errors' => array(array('code' => $errorCode, 'field' => 'test', 'resource' => 'fake')));
     $response = $this->getMock('Github\\HttpClient\\Message\\Response');
     $response->expects($this->once())->method('isClientError')->will($this->returnValue(true));
     $response->expects($this->once())->method('getHeader')->with('X-RateLimit-Remaining')->will($this->returnValue(5000));
     $response->expects($this->once())->method('getContent')->will($this->returnValue($content));
     $response->expects($this->any())->method('getStatusCode')->will($this->returnValue(422));
     $listener = new ErrorListener(array('api_limit' => 5000));
     $listener->postSend($this->getMock('Buzz\\Message\\RequestInterface'), $response);
 }
Пример #2
0
 /**
  * @test
  * @dataProvider getErrorCodesProvider
  * @expectedException \Github\Exception\ValidationFailedException
  */
 public function shouldNotPassWhen422IsSentWithErrorCode($errorCode)
 {
     $content = json_encode(array('message' => 'Validation Failed', 'errors' => array(array('code' => $errorCode, 'field' => 'test', 'value' => 'wrong', 'resource' => 'fake'))));
     $response = $this->getMockBuilder('Guzzle\\Http\\Message\\Response')->disableOriginalConstructor()->getMock();
     $response->expects($this->once())->method('isClientError')->will($this->returnValue(true));
     $response->expects($this->once())->method('getHeader')->with('X-RateLimit-Remaining')->will($this->returnValue(5000));
     $response->expects($this->once())->method('getBody')->will($this->returnValue($content));
     $response->expects($this->any())->method('getStatusCode')->will($this->returnValue(422));
     $listener = new ErrorListener(array('api_limit' => 5000));
     $listener->onRequestError($this->getEventMock($response));
 }