|
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); |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
$this->assertEquals($id, $timeCards[0]->getId()); |
|
47
|
|
|
$this->assertEquals($title, $timeCards[0]->getTitle()); |
|
48
|
|
|
$this->assertEquals([], $timeCards[0]->getCycleTimes()); |
|
49
|
|
|
} |
|
50
|
|
|
} |
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: