|
@@ 144-156 (lines=13) @@
|
| 141 |
|
/** |
| 142 |
|
* @expectedException \IBM\Watson\Common\Exception\InvalidRequestException |
| 143 |
|
*/ |
| 144 |
|
public function testErrors() |
| 145 |
|
{ |
| 146 |
|
$rawResponse = self::errorResponse(); |
| 147 |
|
|
| 148 |
|
$this->httpClient->shouldReceive('sendRequest')->once()->andReturnUsing(function () use ($rawResponse) { |
| 149 |
|
return new Response(400, ['Content-Type' => 'application/json'], $rawResponse); |
| 150 |
|
}); |
| 151 |
|
|
| 152 |
|
$classifier = new Classify($this->httpClient, $this->hydrator, $this->requestBuilder); |
| 153 |
|
|
| 154 |
|
$classifier->classify('src/VisualRecognition/tests/images/flower.jpg'); |
| 155 |
|
$classifier->classify('http://someurl.com/image.jpg'); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
/** |
| 159 |
|
* @expectedException \IBM\Watson\Common\Exception\InvalidRequestException |
|
@@ 161-172 (lines=12) @@
|
| 158 |
|
/** |
| 159 |
|
* @expectedException \IBM\Watson\Common\Exception\InvalidRequestException |
| 160 |
|
*/ |
| 161 |
|
public function testUrlErrors() |
| 162 |
|
{ |
| 163 |
|
$rawResponse = self::errorResponse(); |
| 164 |
|
|
| 165 |
|
$this->httpClient->shouldReceive('sendRequest')->once()->andReturnUsing(function () use ($rawResponse) { |
| 166 |
|
return new Response(400, ['Content-Type' => 'application/json'], $rawResponse); |
| 167 |
|
}); |
| 168 |
|
|
| 169 |
|
$classifier = new Classify($this->httpClient, $this->hydrator, $this->requestBuilder); |
| 170 |
|
|
| 171 |
|
$classifier->classify('http://someurl.com/image.jpg'); |
| 172 |
|
} |
| 173 |
|
} |
| 174 |
|
|