Passed
Push — master ( 5ca0ef...7a5018 )
by Alessandro
01:44 queued 12s
created

TimeCardsTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateCollectionWithNoData() 0 10 1
A testCreateCollection() 0 25 1
1
<?php
2
3
4
namespace Tests\Collection;
5
6
7
use PHPUnit\Framework\TestCase;
8
use TrelloCycleTime\Collection\HistoryCards;
9
use TrelloCycleTime\Collection\TimeCards;
10
use TrelloCycleTime\ValueObject\HistoryCard;
11
12
class TimeCardsTest extends TestCase
13
{
14
    public function testCreateCollectionWithNoData()
15
    {
16
        $historyCards = $this->prophesize(HistoryCards::class);
17
        $historyCards->getCardHistories()->willReturn([]);
18
19
        $timeCards = new TimeCards();
20
        $timeCards = $timeCards->getFromHistoryCards($historyCards->reveal());
21
22
        $this->assertEquals([], $timeCards);
23
    }
24
25
    public function testCreateCollection()
26
    {
27
        $id = 1;
28
        $title = 'cardTitle';
29
        $from = 'from';
30
        $to = 'to';
31
32
        $historyCard = $this->prophesize(HistoryCard::class);
33
        $historyCard->getId()->willReturn($id);
34
        $historyCard->getTitle()->willReturn($title);
35
        $historyCard->getFrom()->willReturn($from);
36
        $historyCard->getTo()->willReturn($to);
37
38
        $historyCards = $this->prophesize(HistoryCards::class);
39
        $historyCards->getCardHistories()->willReturn([$historyCard->reveal()]);
40
41
        $timeCards = new TimeCards();
42
        $timeCards = $timeCards->getFromHistoryCards($historyCards->reveal());
43
44
        $this->assertCount(1, $timeCards);
0 ignored issues
show
Documentation introduced by
$timeCards 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...
45
46
        $this->assertEquals($id, $timeCards[0]->getId());
47
        $this->assertEquals($title, $timeCards[0]->getTitle());
48
        $this->assertEquals([], $timeCards[0]->getCycleTimes());
49
    }
50
}