Passed
Push — master ( 5ee49d...ede548 )
by Alessandro
01:05 queued 11s
created

testExecuteWithEmptyData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use TrelloCycleTime\Collection\HistoryCards;
7
use TrelloCycleTime\CycleTimeCalculator;
8
use TrelloCycleTime\ValueObject\HistoryCard;
9
use TrelloCycleTime\ValueObject\TimeCard;
10
11
class CycleTimeCalculatorTest extends TestCase
12
{
13
    private $historyCards;
14
    private $cycleTimeCalculator;
15
16
    public function setUp()
17
    {
18
        $this->historyCards = $this->prophesize(HistoryCards::class);
19
        $this->cycleTimeCalculator = new CycleTimeCalculator([], $this->historyCards->reveal());
20
    }
21
22
    public function testCalculateFromCardHistoryWithEmptyData()
23
    {
24
        $historyCard = $this->prophesize(HistoryCard::class);
25
        $this->historyCards->getCardHistories()->willReturn([]);
26
        $this->cycleTimeCalculator->calculateFromCardHistory($historyCard->reveal());
0 ignored issues
show
Unused Code introduced by
The call to CycleTimeCalculator::calculateFromCardHistory() has too many arguments starting with $historyCard->reveal().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
27
28
        $this->assertEquals([], $this->cycleTimeCalculator->getTimeCards());
29
    }
30
31
    public function testCalculateFromCardHistory()
32
    {
33
        $cardId = 1;
34
        $fromKey = 'from';
35
        $toKey = 'to';
36
        $fromDate = '2019-05-25 00:00:00';
37
        $toDate = '2019-05-26 00:00:00';
38
39
        $historyCard = $this->prophesize(HistoryCard::class);
40
        $historyCard->getId()->willReturn($cardId);
41
        $historyCard->getFrom()->willReturn($fromKey);
42
        $historyCard->getTo()->willReturn($toKey);
43
44
        $timeCard = $this->prophesize(TimeCard::class);
45
        $timeCard->getId()->willReturn($cardId);
46
        $timeCard->calculateDayDifferenceBetweenColumns($fromKey, $fromDate, $toKey, $toDate)->shouldBeCalled();
47
48
        $this->historyCards->getCardHistories()->willReturn([$historyCard->reveal()]);
49
        $this->historyCards->getByCardIdAndTo($cardId, $fromKey)->willReturn($fromDate);
50
        $this->historyCards->getByCardIdAndTo($cardId, $toKey)->willReturn($toDate);
51
52
        $timeCardsCollection = [
53
            $timeCard->reveal()
54
        ];
55
56
        $this->cycleTimeCalculator = new CycleTimeCalculator($timeCardsCollection, $this->historyCards->reveal());
57
        $this->cycleTimeCalculator->calculateFromCardHistory();
58
    }
59
}