|
@@ 114-126 (lines=13) @@
|
| 111 |
|
* |
| 112 |
|
* @expectedException \InvalidArgumentException |
| 113 |
|
*/ |
| 114 |
|
public function testIncorrectFileApiResponse() |
| 115 |
|
{ |
| 116 |
|
$container = []; |
| 117 |
|
$response = new Response(415, [], '{"code":415,"error":"Unsupported image type"}'); |
| 118 |
|
$httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]); |
| 119 |
|
|
| 120 |
|
$client = new Client($httpClient); |
| 121 |
|
$client->initialize(['username' => 'test', 'password' => 'test']); |
| 122 |
|
|
| 123 |
|
/** @var ClassifyRequest $request */ |
| 124 |
|
$request = $client->classify(['images_file' => 'Tests/images/hummingbird-1047836_640.jpg']); |
| 125 |
|
$request->send(); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
/** |
| 129 |
|
* Test failed auth is handled appropriately |
|
@@ 133-145 (lines=13) @@
|
| 130 |
|
* |
| 131 |
|
* @expectedException \Bobbyshaw\WatsonVisualRecognition\Exceptions\AuthException |
| 132 |
|
*/ |
| 133 |
|
public function testFailedAuth() |
| 134 |
|
{ |
| 135 |
|
$container = []; |
| 136 |
|
$response = $this->getMockHttpResponse('FailedAuth.txt', 401); |
| 137 |
|
$httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]); |
| 138 |
|
|
| 139 |
|
$client = new Client($httpClient); |
| 140 |
|
$client->initialize(['username' => 'test', 'password' => 'test']); |
| 141 |
|
|
| 142 |
|
/** @var ClassifyRequest $request */ |
| 143 |
|
$request = $client->classify(['images_file' => 'Tests/images/hummingbird-1047836_640.jpg']); |
| 144 |
|
$request->send(); |
| 145 |
|
} |
| 146 |
|
} |
| 147 |
|
|