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

CycleTimeCalculatorTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testCalculateFromCardHistoryWithEmptyData() 0 8 1
A testCalculateFromCardHistory() 0 28 1
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
}