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

GetClassifiersCommandTest::testCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Bobbyshaw\WatsonVisualRecognition\Tests\Commands;
4
5
use Bobbyshaw\WatsonVisualRecognition\Client;
6
use Bobbyshaw\WatsonVisualRecognition\Commands\GetClassifiersCommand;
7
use Bobbyshaw\WatsonVisualRecognition\Tests\Base;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Output\BufferedOutput;
10
11
class GetClassifiersCommandTest extends Base
12
{
13
    /**
14
     * Test that the command outputs a table of classifiers
15
     */
16
    public function testCommand()
17
    {
18
        $container = [];
19
        $response = $this->getMockHttpResponse('GetClassifiersSuccess.txt');
20
        $httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]);
21
22
        $arguments = [
23
            'username' => 'test',
24
            'password' => 'test',
25
            '--version-date' => '2016-01-01'
26
        ];
27
        $input = new ArrayInput($arguments);
28
        $output = new BufferedOutput();
29
30
        $command = new GetClassifiersCommand(null, new Client($httpClient));
31
        $command->run($input, $output);
32
33
        $this->assertEquals('classifiers:get', $command->getName());
34
35
        $correctOutput = file_get_contents('Tests/Mock/Commands/ClassifiersSuccess.txt');
36
37
        $this->assertEquals($correctOutput, $output->fetch());
38
    }
39
40 View Code Duplication
    public function testVerboseCommand()
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...
41
    {
42
        $container = [];
43
        $response = $this->getMockHttpResponse('GetClassifiersVerbose.txt');
44
        $httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]);
45
46
        $arguments = [
47
            'username' => 'test',
48
            'password' => 'test',
49
            '--version-date' => '2016-01-01',
50
            '--api-verbose'  => 'true'
51
        ];
52
        $input = new ArrayInput($arguments);
53
        $output = new BufferedOutput();
54
55
        $command = new GetClassifiersCommand(null, new Client($httpClient));
56
        $command->run($input, $output);
57
58
        $this->assertEquals('classifiers:get', $command->getName());
59
60
        $correctOutput = file_get_contents('Tests/Mock/Commands/ClassifiersVerboseSuccess.txt');
61
62
        $this->assertEquals($correctOutput, $output->fetch());
63
    }
64
}
65