ExecuteCommandTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 31
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 10 10 1
A testGetInputCommand() 5 5 1
A testGetInputCommandWithParams() 9 9 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 ReddogsTest\Doctrine\Migrations;
4
5
use Reddogs\Doctrine\Migrations\ModuleConfig;
6
use ZF\Console\Route;
7
use Reddogs\Doctrine\Migrations\ExecuteCommand;
8
9 View Code Duplication
class ExecuteCommandTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    private $command, $route;
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
12
13
    protected function setUp()
14
    {
15
        $this->command = $this->getMockBuilder(ExecuteCommand::class)
16
            ->disableOriginalConstructor()
17
            ->setMethods(['null'])
18
            ->getMock();
19
        $moduleConfig = (new ModuleConfig())->__invoke();
20
        $migrateParams = $moduleConfig['console_routes']['mogrations:execute'];
21
        $this->route = new Route($migrateParams['name'], $migrateParams['route']);
22
    }
23
24
    public function testGetInputCommand()
25
    {
26
        $this->route->match(['mogrations:execute']);
27
        $this->assertSame('migrations:execute', $this->command->getInputCommand($this->route));
28
    }
29
30
    public function testGetInputCommandWithParams()
31
    {
32
        $this->route->match([
33
            'mogrations:execute', 'testModuleName', '--version=testVersion', '--dry-run', '--write-sql',
34
            '--query-time', '-n', '-q', '--verbose'
35
        ]);
36
        $expected = 'migrations:execute --dry-run --write-sql --query-time -n -q --verbose testVersion';
37
        $this->assertEquals($expected, $this->command->getInputCommand($this->route));
38
    }
39
}