public function testInitialize()
 {
     $config = array('username' => $this->username, 'password' => $this->password);
     $this->client = new Client();
     $this->client->initialize($config);
     $this->assertEquals($this->username, $this->client->getUsername());
     $this->assertEquals($this->password, $this->client->getPassword());
 }
 /**
  * @expectedException \RuntimeException
  */
 public function testSetUsernameOnRequestAfterResponse()
 {
     $container = [];
     $guzzle = $this->getMockHttpClientWithHistoryAndResponses($container, [$this->getMockHttpResponse('GetClassifiersSuccess.txt')]);
     $client = new Client($guzzle);
     $client->initialize(['username' => 'test', 'password' => 'test']);
     $request = $client->getClassifiers();
     $request->send();
     $request->setUsername('test2');
 }
 /**
  * Test deleteClassifier failed auth is handled appropriately
  *
  * @expectedException \Bobbyshaw\WatsonVisualRecognition\Exceptions\AuthException
  */
 public function testDeleteClassifierFailedAuthResponse()
 {
     $container = [];
     $response = $this->getMockHttpResponse('FailedAuth.txt', 401);
     $httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]);
     $this->client = new Client($httpClient);
     $this->client->initialize(['username' => $this->username, 'password' => $this->password]);
     /** @var DeleteClassifierRequest $request */
     $request = $this->client->deleteClassifier(['classifier_id' => $this->classifierId]);
     $request->send();
 }
 public function testGetClassifiersVerbose()
 {
     $container = [];
     $guzzle = $this->getMockHttpClientWithHistoryAndResponses($container, [$this->getMockHttpResponse('GetClassifiersSuccess.txt')]);
     $this->client = new Client($guzzle);
     $this->client->initialize(['username' => $this->username, 'password' => $this->password]);
     /** @var GetClassifiersRequest $request */
     $classifiersRequest = $this->client->getClassifiers(['verbose' => 'true']);
     /** @var ClassifiersResponse $response */
     $response = $classifiersRequest->send();
     $response->getClassifiers();
     $transaction = $container[0];
     /** @var Request $request */
     $request = $transaction['request'];
     /** @var Uri $uri */
     $uri = $request->getUri();
     // Check verbose query parameter
     $query = \GuzzleHttp\Psr7\parse_query($uri->getQuery());
     $this->assertArrayHasKey('verbose', $query);
 }
 /**
  * Test failed auth is handled appropriately
  *
  * @expectedException \Bobbyshaw\WatsonVisualRecognition\Exceptions\AuthException
  */
 public function testFailedAuth()
 {
     $container = [];
     $response = $this->getMockHttpResponse('FailedAuth.txt', 401);
     $httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]);
     $client = new Client($httpClient);
     $client->initialize(['username' => 'test', 'password' => 'test']);
     /** @var ClassifyRequest $request */
     $request = $client->classify(['images_file' => 'Tests/images/hummingbird-1047836_640.jpg']);
     $request->send();
 }
 /**
  * Pass incorrect file types to request to
  *
  * @expectedException \InvalidArgumentException
  */
 public function testInvalidData()
 {
     $client = new Client();
     $client->initialize(['username' => 'test', 'password' => 'test']);
     /** @var CreateClassifierRequest $request */
     $request = $client->createClassifier(['positive_examples' => 'test.log', 'negative_examples' => 'test.log', 'name' => 'test']);
     $request->send();
 }