testGetAllCycleTimeColumns()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Tests\Collection;
4
5
6
use PHPUnit\Framework\TestCase;
7
use TrelloCycleTime\Collection\CycleTimesCollection;
8
use TrelloCycleTime\ValueObject\HistoryCard;
9
10
class CycleTimeCollectionTest extends TestCase
11
{
12
    private $cycleTimeCollection;
13
14
    public function setUp()
15
    {
16
        $this->cycleTimeCollection = new CycleTimesCollection();
17
    }
18
19
    public function testGetAllCycleTimeColumnsWithEmptyData()
20
    {
21
        $cycleTime = $this->cycleTimeCollection->getFromCardHistory([]);
22
23
        $this->assertEquals([], $cycleTime);
24
    }
25
26
    public function testGetAllCycleTimeColumns()
27
    {
28
        $from = 'from';
29
        $to = 'to';
30
31
        $cardHistory = $this->prophesize(HistoryCard::class);
32
        $cardHistory->getFrom()->willReturn($from);
33
        $cardHistory->getTo()->willReturn($to);
34
35
        $cardHistory2 = $this->prophesize(HistoryCard::class);
36
        $cardHistory2->getFrom()->willReturn($from);
37
        $cardHistory2->getTo()->willReturn($to);
38
39
        $cardHistories = [
40
            $cardHistory->reveal(),
41
            $cardHistory->reveal(),
42
            $cardHistory2->reveal()
43
        ];
44
45
        $cycleTimes = $this->cycleTimeCollection->getFromCardHistory($cardHistories);
46
47
        $this->assertCount(1, $cycleTimes);
0 ignored issues
show
Documentation introduced by
$cycleTimes 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...
48
49
        foreach ($cycleTimes as $cycleTimeColumn) {
50
            $this->assertEquals('from', $cycleTimeColumn->getFrom());
51
            $this->assertEquals('to', $cycleTimeColumn->getTo());
52
            $this->assertEquals('from_to', $cycleTimeColumn->getName());
53
        }
54
    }
55
}