|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Scrumban\Tests\Manager; |
|
4
|
|
|
|
|
5
|
|
|
use Scrumban\Manager\SprintManager; |
|
6
|
|
|
|
|
7
|
|
|
use Scrumban\Entity\Sprint; |
|
8
|
|
|
|
|
9
|
|
|
class SprintManagerTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
/** @var SprintManager **/ |
|
12
|
|
|
protected $manager; |
|
13
|
|
|
|
|
14
|
|
|
public function setUp() |
|
15
|
|
|
{ |
|
16
|
|
|
$this->manager = new SprintManager($this->getObjectManagerMock(), $this->getEventDispatcherMock()); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function testGet() |
|
20
|
|
|
{ |
|
21
|
|
|
$sprint = $this->manager->get(4); |
|
22
|
|
|
|
|
23
|
|
|
$this->assertInstanceOf(Sprint::class, $sprint); |
|
24
|
|
|
$this->assertEquals(4, $sprint->getId()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testCurrentSprint() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->assertInstanceOf(Sprint::class, $this->manager->getCurrentSprint()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testCreate() |
|
33
|
|
|
{ |
|
34
|
|
|
$beginAt = new \DateTime('+12 days'); |
|
35
|
|
|
$endedAt = new \DateTime('+26 days'); |
|
36
|
|
|
$sprint = $this->manager->createSprint($beginAt, $endedAt); |
|
37
|
|
|
|
|
38
|
|
|
$this->assertInstanceOf(Sprint::class, $sprint); |
|
39
|
|
|
$this->assertEquals($beginAt, $sprint->getBeginAt()); |
|
40
|
|
|
$this->assertEquals($endedAt, $sprint->getEndedAt()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException |
|
45
|
|
|
* @expectedExceptionMessage The begin date must preceed the end date |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testCreateWithInvalidDates() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->manager->createSprint(new \DateTime('+5 days'), new \DateTime('+3 days')); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @expectedException \Symfony\Component\HttpKernel\Exception\ConflictHttpException |
|
54
|
|
|
*/ |
|
55
|
|
|
public function testCreateWithConflict() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->manager->createSprint(new \DateTime('+2 days'), new \DateTime('+16 days')); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getObjectManagerMock() |
|
61
|
|
|
{ |
|
62
|
|
|
$objectManagerMock = $this->createMock(\Doctrine\Common\Persistence\ObjectManager::class); |
|
63
|
|
|
$objectManagerMock |
|
64
|
|
|
->expects($this->any()) |
|
65
|
|
|
->method('persist') |
|
66
|
|
|
->willReturn(true) |
|
67
|
|
|
; |
|
68
|
|
|
$objectManagerMock |
|
69
|
|
|
->expects($this->any()) |
|
70
|
|
|
->method('flush') |
|
71
|
|
|
->willReturn(true) |
|
72
|
|
|
; |
|
73
|
|
|
$objectManagerMock |
|
74
|
|
|
->expects($this->any()) |
|
75
|
|
|
->method('getRepository') |
|
76
|
|
|
->willReturnCallback([$this, 'getRepositoryMock']) |
|
77
|
|
|
; |
|
78
|
|
|
return $objectManagerMock; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function getRepositoryMock() |
|
82
|
|
|
{ |
|
83
|
|
|
$repositoryMock = $this |
|
84
|
|
|
->getMockBuilder(\Scrumban\Repository\SprintRepository::class) |
|
85
|
|
|
->disableOriginalConstructor() |
|
86
|
|
|
->getMock() |
|
87
|
|
|
; |
|
88
|
|
|
$repositoryMock |
|
89
|
|
|
->expects($this->any()) |
|
90
|
|
|
->method('getCurrentSprint') |
|
91
|
|
|
->willReturnCallback([$this, 'getSprintMock']) |
|
92
|
|
|
; |
|
93
|
|
|
$repositoryMock |
|
94
|
|
|
->expects($this->any()) |
|
95
|
|
|
->method('find') |
|
96
|
|
|
->willReturnCallback([$this, 'getSprintMock']) |
|
97
|
|
|
; |
|
98
|
|
|
$repositoryMock |
|
99
|
|
|
->expects($this->any()) |
|
100
|
|
|
->method('getSprintByPeriod') |
|
101
|
|
|
->willReturnCallback(function($beginDate) { |
|
102
|
|
|
$sprint = $this->getSprintMock(3); |
|
103
|
|
|
|
|
104
|
|
|
return ($beginDate < $sprint->getEndedAt()) ? [$sprint]: []; |
|
105
|
|
|
}); |
|
106
|
|
|
return $repositoryMock; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function getSprintMock($id = null) |
|
110
|
|
|
{ |
|
111
|
|
|
$sprint = |
|
112
|
|
|
(new Sprint()) |
|
113
|
|
|
->setDemoUrl('http://example.org/demo.flv') |
|
114
|
|
|
->setBeginAt(new \DateTime('-3 days')) |
|
115
|
|
|
->setEndedAt(new \DateTime('+11 days')) |
|
116
|
|
|
; |
|
117
|
|
|
if($id !== null) { |
|
118
|
|
|
$sprint->setId($id); |
|
119
|
|
|
} |
|
120
|
|
|
return $sprint; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function getEventDispatcherMock() |
|
124
|
|
|
{ |
|
125
|
|
|
$dispatcherMock = $this->createMock(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class); |
|
126
|
|
|
$dispatcherMock |
|
127
|
|
|
->expects($this->any()) |
|
128
|
|
|
->method('dispatch') |
|
129
|
|
|
->willReturn(true) |
|
130
|
|
|
; |
|
131
|
|
|
return $dispatcherMock; |
|
132
|
|
|
} |
|
133
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths