Completed
Push — develop ( fe8c75...3bcd98 )
by Tom
02:26
created

ClassifiersResponseTest::testVerbose()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 19
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 19
loc 19
rs 9.4285
cc 2
eloc 11
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 View Code Duplication
    public function testSuccess()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
    /**
55
     * Test versbose response
56
     */
57 View Code Duplication
    public function testVerbose()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        /** @var RequestInterface $httpRequest */
60
        $httpRequest = $this->getMockForAbstractClass(RequestInterface::class);
61
        $httpResponse = $this->getMockHttpResponse('GetClassifiersVerbose.txt');
62
63
        $response = new ClassifiersResponse($httpRequest, $httpResponse->getBody());
64
65
        $classifiers = $response->getClassifiers();
66
67
        $this->assertTrue($response->isSuccessful());
68
        $this->assertCount(713, $classifiers);
69
70
        foreach ($classifiers as $classifier) {
71
            $this->assertInstanceOf(Classifier::class, $classifier);
72
            $this->assertInstanceOf(\DateTime::class, $classifier->getCreated());
73
            $this->assertEquals('IBM', $classifier->getOwner());
74
        }
75
    }
76
}
77