|
@@ 59-67 (lines=9) @@
|
| 56 |
|
* @expectedException \IBM\Watson\Common\Exception\HydrationException |
| 57 |
|
* @expectedExceptionMessage The ModelHydrator cannot hydrate a response with Content-Type: text/plain |
| 58 |
|
*/ |
| 59 |
|
public function testNoneJsonExceptionIsThrown() |
| 60 |
|
{ |
| 61 |
|
$this->stream->shouldReceive('__toString')->once()->andReturn('Plain text response'); |
| 62 |
|
$this->response->shouldReceive('getHeaderLine')->andReturn('text/plain'); |
| 63 |
|
$this->response->shouldReceive('getBody')->once()->andReturn($this->stream); |
| 64 |
|
|
| 65 |
|
$hydrator = new ModelHydrator(); |
| 66 |
|
$hydrator->hydrate($this->response, get_class($this->model)); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
/** |
| 70 |
|
* @expectedException \IBM\Watson\Common\Exception\HydrationException |
|
@@ 72-81 (lines=10) @@
|
| 69 |
|
/** |
| 70 |
|
* @expectedException \IBM\Watson\Common\Exception\HydrationException |
| 71 |
|
*/ |
| 72 |
|
public function testInvalidJsonExceptionIsThrown() |
| 73 |
|
{ |
| 74 |
|
$this->stream->shouldReceive('__toString')->once()->andReturn('{param:value}'); |
| 75 |
|
|
| 76 |
|
$this->response->shouldReceive('getHeaderLine')->once()->andReturn('application/json'); |
| 77 |
|
$this->response->shouldReceive('getBody')->once()->andReturn($this->stream); |
| 78 |
|
|
| 79 |
|
$hydrator = new ModelHydrator(); |
| 80 |
|
$hydrator->hydrate($this->response, get_class($this->model)); |
| 81 |
|
} |
| 82 |
|
} |