1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bobbyshaw\WatsonVisualRecognition\Tests\Message; |
4
|
|
|
|
5
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Classifier; |
6
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Message\ClassifiersResponse; |
7
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Message\RequestInterface; |
8
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Tests\Base; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class ClassifiersResponseTest |
12
|
|
|
* @package Bobbyshaw\WatsonVisualRecognition\Tests\Message |
13
|
|
|
*/ |
14
|
|
|
class ClassifiersResponseTest extends Base |
15
|
|
|
{ |
16
|
|
|
protected $images = array('cosmos-flower-433424_640.jpg', 'hummingbird-1047836_640.jpg'); |
17
|
|
|
|
18
|
|
|
protected $classifiers = [ |
19
|
|
|
"Black" => "Black", |
20
|
|
|
"Blue" => "Blue", |
21
|
|
|
"Brown" => "Brown", |
22
|
|
|
"Cyan" => "Cyan", |
23
|
|
|
"Green" => "Green", |
24
|
|
|
"Magenta" => "Magenta", |
25
|
|
|
"Mixed_Color" => "Mixed_Color", |
26
|
|
|
"Orange" => "Orange", |
27
|
|
|
"Red" => "Red", |
28
|
|
|
"Violet" => "Violet", |
29
|
|
|
"White" => "White", |
30
|
|
|
"Yellow" => "Yellow", |
31
|
|
|
"Black_and_white" => "Black_and_white", |
32
|
|
|
"Color" => "Color", |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
public function testSuccess() |
36
|
|
|
{ |
37
|
|
|
/** @var RequestInterface $httpRequest */ |
38
|
|
|
$httpRequest = $this->getMockForAbstractClass(RequestInterface::class); |
39
|
|
|
$httpResponse = $this->getMockHttpResponse('GetClassifiersSuccess.txt'); |
40
|
|
|
|
41
|
|
|
$response = new ClassifiersResponse($httpRequest, $httpResponse->getBody()); |
42
|
|
|
|
43
|
|
|
$classifiers = $response->getClassifiers(); |
44
|
|
|
|
45
|
|
|
$this->assertTrue($response->isSuccessful()); |
46
|
|
|
$this->assertCount(14, $classifiers); |
47
|
|
|
|
48
|
|
|
foreach ($classifiers as $classifier) { |
49
|
|
|
$this->assertInstanceOf(Classifier::class, $classifier); |
50
|
|
|
$this->assertContains($classifier->getName(), $this->classifiers); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|