Test Failed
Push — master ( fdad3b...1a9d53 )
by Mike
07:27
created

FacadeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 65
Duplicated Lines 40 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 0 4 1
A testHydrateCommandsRecusive() 15 15 1
A testHydrateCommandsNotRecusive() 11 11 1
A testHydrateCommandsWithNonExistingDirectory() 0 6 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
namespace NexusTest\CustomCommand;
3
4
use Nexus\CustomCommand\Command\TestRecursiveCommand;
5
use Xervice\Core\Locator\Locator;
6
use XerviceTest\Console\Command\TestCommand;
7
8
class FacadeTest extends \Codeception\Test\Unit
9
{
10
    /**
11
     * @var \Nexus\CustomCommand\CustomCommandFacade
12
     */
13
    private $facade;
14
15
    protected function _before()
16
    {
17
        $this->facade = Locator::getInstance()->customCommand()->facade();
18
    }
19
20
    /**
21
     * @group Nexus
22
     * @group CustomCommand
23
     * @group Facade
24
     * @group Integration
25
     */
26 View Code Duplication
    public function testHydrateCommandsRecusive()
0 ignored issues
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...
27
    {
28
        $commands = $this->facade->hydrateCommands([], __DIR__ . '/test', true);
29
30
        $this->assertCount(2, $commands);
0 ignored issues
show
Documentation introduced by
$commands is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
32
        $this->assertInstanceOf(
33
            'Nexus\\CustomCommand\\Command\\TestRecursiveCommand',
34
            $commands[0]
35
        );
36
        $this->assertInstanceOf(
37
            'Nexus\\CustomCommand\\Command\\TestCommand',
38
            $commands[1]
39
        );
40
    }
41
42
    /**
43
     * @group Nexus
44
     * @group CustomCommand
45
     * @group Facade
46
     * @group Integration
47
     */
48 View Code Duplication
    public function testHydrateCommandsNotRecusive()
0 ignored issues
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...
49
    {
50
        $commands = $this->facade->hydrateCommands([], __DIR__ . '/test', false);
51
52
        $this->assertCount(1, $commands);
0 ignored issues
show
Documentation introduced by
$commands is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
53
54
        $this->assertInstanceOf(
55
            'Nexus\\CustomCommand\\Command\\TestCommand',
56
            $commands[0]
57
        );
58
    }
59
60
    /**
61
     * @group Nexus
62
     * @group CustomCommand
63
     * @group Facade
64
     * @group Integration
65
     */
66
    public function testHydrateCommandsWithNonExistingDirectory()
67
    {
68
        $commands = $this->facade->hydrateCommands([], __DIR__ . '/notExisting', false);
69
70
        $this->assertCount(0, $commands);
0 ignored issues
show
Documentation introduced by
$commands is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
71
    }
72
}