| @@ 67-82 (lines=16) @@ | ||
| 64 | /** |
|
| 65 | * @expectedException \RuntimeException |
|
| 66 | */ |
|
| 67 | public function testInitialisingRequestAfterResponse() |
|
| 68 | { |
|
| 69 | $container = []; |
|
| 70 | $guzzle = $this->getMockHttpClientWithHistoryAndResponses( |
|
| 71 | $container, |
|
| 72 | [$this->getMockHttpResponse('GetClassifiersSuccess.txt')] |
|
| 73 | ); |
|
| 74 | ||
| 75 | $client = new Client($guzzle); |
|
| 76 | $client->initialize(['username' => 'test', 'password' => 'test']); |
|
| 77 | ||
| 78 | $request = $client->getClassifiers(); |
|
| 79 | $request->send(); |
|
| 80 | ||
| 81 | $request->initialize(); |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * @expectedException \RuntimeException |
|
| @@ 87-102 (lines=16) @@ | ||
| 84 | /** |
|
| 85 | * @expectedException \RuntimeException |
|
| 86 | */ |
|
| 87 | public function testSetUsernameOnRequestAfterResponse() |
|
| 88 | { |
|
| 89 | $container = []; |
|
| 90 | $guzzle = $this->getMockHttpClientWithHistoryAndResponses( |
|
| 91 | $container, |
|
| 92 | [$this->getMockHttpResponse('GetClassifiersSuccess.txt')] |
|
| 93 | ); |
|
| 94 | ||
| 95 | $client = new Client($guzzle); |
|
| 96 | $client->initialize(['username' => 'test', 'password' => 'test']); |
|
| 97 | ||
| 98 | $request = $client->getClassifiers(); |
|
| 99 | $request->send(); |
|
| 100 | ||
| 101 | $request->setUsername('test2'); |
|
| 102 | } |
|
| 103 | } |
|
| 104 | ||
| @@ 103-115 (lines=13) @@ | ||
| 100 | * |
|
| 101 | * @expectedException \Bobbyshaw\WatsonVisualRecognition\Exceptions\AuthException |
|
| 102 | */ |
|
| 103 | public function testCreateClassifierFailedAuthResponse() |
|
| 104 | { |
|
| 105 | $container = []; |
|
| 106 | $response = $this->getMockHttpResponse('FailedAuth.txt', 401); |
|
| 107 | $httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]); |
|
| 108 | ||
| 109 | $client = new Client($httpClient); |
|
| 110 | $client->initialize(['username' => 'test', 'password' => 'test']); |
|
| 111 | ||
| 112 | /** @var CreateClassifierRequest $request */ |
|
| 113 | $request = $client->createClassifier($this->request->getData()); |
|
| 114 | $request->send(); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Pass incorrect file types to request to |
|