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

FacadeTest::testHydrateCommandsRecusive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
}