Ejemplo n.º 1
0
 /**
  * @test
  * @dataProvider providerHasError
  */
 public function testHasError($format, $content)
 {
     $message = $this->getMock('\\http\\Client\\Response', array('getBody', 'getResponseCode'), array(''));
     //It returns 500 error
     $message->expects($this->any())->method('getResponseCode')->will($this->returnValue(500));
     //Content should have error message in appropriated application format
     $message->expects($this->once())->method('getBody')->will($this->returnValue((new Body())->append($content)));
     $response = new RestClientResponse($message, $format);
     try {
         $response->hasError();
         $this->assertTrue(false, 'Exception are expected to be thrown here.');
     } catch (RestClientException $e) {
         $this->assertTrue(true);
         $this->assertInstanceOf($this->getOpenStackClassName('Client\\ErrorData'), $e->error);
         $this->assertEquals(500, $e->error->code);
         $this->assertEquals('Fault!', $e->error->message);
         $this->assertEquals('Error Details...', $e->error->details);
     }
 }