GetClassifierCommandTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 80 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 1
cbo 3
dl 24
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testCommand() 24 24 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Bobbyshaw\WatsonVisualRecognition\Tests\Commands;
4
5
use Bobbyshaw\WatsonVisualRecognition\Client;
6
use Bobbyshaw\WatsonVisualRecognition\Commands\GetClassifierCommand;
7
use Bobbyshaw\WatsonVisualRecognition\Tests\Base;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Output\BufferedOutput;
10
11
class GetClassifierCommandTest extends Base
12
{
13
    /**
14
     * Test that the command outputs a table of classifiers
15
     */
16 View Code Duplication
    public function testCommand()
17
    {
18
        $container = [];
19
        $response = $this->getMockHttpResponse('GetClassifierSuccess.txt');
20
        $httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]);
21
22
        $arguments = [
23
            'username' => 'test',
24
            'password' => 'test',
25
            'classifier_id' => 'Magenta',
26
            '--version-date' => '2016-01-01',
27
        ];
28
        $input = new ArrayInput($arguments);
29
        $output = new BufferedOutput();
30
31
        $command = new GetClassifierCommand(null, new Client($httpClient));
32
        $command->run($input, $output);
33
34
        $this->assertEquals('classifier:get', $command->getName());
35
36
        $correctOutput = file_get_contents('Tests/Mock/Commands/ClassifierSuccess.txt');
37
38
        $this->assertEquals($correctOutput, $output->fetch());
39
    }
40
}
41