/**
  * Check that exception is thrown if incorrect file type provided
  *
  * @expectedException \InvalidArgumentException
  */
 public function testDisallowedFileType()
 {
     $request = $this->getMockHttpResponse('ClassifySuccess.txt');
     $httpClient = $this->getMockHttpClientWithHistoryAndResponses($this->container, [$request]);
     $this->request = new ClassifyRequest($httpClient);
     $this->request->initialize(['images_file' => 'Tests/images/hummingbird-1047836_640.tom']);
     $this->request->send();
 }
 /**
  * Test that the Classifier POST HTTP Request is sent
  * and contains the correct data
  */
 public function testSendData()
 {
     $this->request->send();
     // Count number of requests sent
     $this->assertEquals(1, count($this->container));
     $transaction = $this->container[0];
     /** @var Request $httpRequest */
     $httpRequest = $transaction['request'];
     $uri = $httpRequest->getUri();
     $this->assertEquals('POST', $httpRequest->getMethod());
     // Check path
     $this->assertEquals('/visual-recognition-beta/api/v2/classifiers/', $uri->getPath());
     // Check post data
     $this->assertStringStartsWith('multipart/form-data', $httpRequest->getHeaderLine('Content-Type'));
     $body = $httpRequest->getBody()->getContents();
     $positiveData = 'Content-Disposition: form-data; name="positive_examples"; filename="butterfly-positive.zip"';
     $this->assertContains($positiveData, $body);
     $negativeData = 'Content-Disposition: form-data; name="negative_examples"; filename="butterfly-negative.zip"';
     $this->assertContains($negativeData, $body);
     $nameData = '/\\bbutterfly\\b/';
     $this->assertRegExp($nameData, $body);
 }