TasksBagTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace tests\Dekalee\NightlyTaskBundle\Bag;
4
5
use Dekalee\NightlyTaskBundle\Bag\TasksBag;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Console\Command\Command;
8
9
class TasksBagTest extends TestCase
10
{
11
    /**
12
     * @var TasksBag
13
     */
14
    protected $bag;
15
16
    /**
17
     * Set up the test
18
     */
19
    public function setUp()
20
    {
21
        $this->bag = new TasksBag();
22
    }
23
24
    /**
25
     * Test get tasks with priority
26
     */
27
    public function testGetTaskWithPriority()
28
    {
29
        $command1 = $this->createMock(Command::CLASS);
30
        $command2 = $this->createMock(Command::CLASS);
31
        $command3 = $this->createMock(Command::CLASS);
32
33
        $this->bag->addTask($command1, 10);
0 ignored issues
show
Documentation introduced by
$command1 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component\Console\Command\Command>.

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...
34
        $this->bag->addTask($command2, 20);
0 ignored issues
show
Documentation introduced by
$command2 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component\Console\Command\Command>.

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...
35
        $this->bag->addTask($command3, 20);
0 ignored issues
show
Documentation introduced by
$command3 is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component\Console\Command\Command>.

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...
36
37
        $this->assertSame([
38
            20 => [
39
                $command2,
40
                $command3
41
            ],
42
            10 => [
43
                $command1
44
            ]
45
        ], $this->bag->getTasks());
46
    }
47
}
48