Completed
Push — develop ( 4ff741...64bd10 )
by Tom
14:53
created

ClassifiersResponseTest::testSuccess()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
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