Kalaxia /
ScrumbanBundle
| 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 |
||
|
0 ignored issues
–
show
|
|||
| 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 testPreviousSprint() |
||
| 33 | { |
||
| 34 | $this->assertInstanceOf(Sprint::class, $this->manager->getPreviousSprint()); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function testCreate() |
||
| 38 | { |
||
| 39 | $beginAt = new \DateTime('+12 days'); |
||
| 40 | $endedAt = new \DateTime('+26 days'); |
||
| 41 | $sprint = $this->manager->createSprint($beginAt, $endedAt); |
||
| 42 | |||
| 43 | $this->assertInstanceOf(Sprint::class, $sprint); |
||
| 44 | $this->assertEquals($beginAt, $sprint->getBeginAt()); |
||
| 45 | $this->assertEquals($endedAt, $sprint->getEndedAt()); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException |
||
| 50 | * @expectedExceptionMessage The begin date must preceed the end date |
||
| 51 | */ |
||
| 52 | public function testCreateWithInvalidDates() |
||
| 53 | { |
||
| 54 | $this->manager->createSprint(new \DateTime('+5 days'), new \DateTime('+3 days')); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @expectedException \Symfony\Component\HttpKernel\Exception\ConflictHttpException |
||
| 59 | */ |
||
| 60 | public function testCreateWithConflict() |
||
| 61 | { |
||
| 62 | $this->manager->createSprint(new \DateTime('+2 days'), new \DateTime('+16 days')); |
||
| 63 | } |
||
| 64 | |||
| 65 | public function getObjectManagerMock() |
||
| 66 | { |
||
| 67 | $objectManagerMock = $this->createMock(\Doctrine\Common\Persistence\ObjectManager::class); |
||
| 68 | $objectManagerMock |
||
| 69 | ->expects($this->any()) |
||
| 70 | ->method('persist') |
||
| 71 | ->willReturn(true) |
||
| 72 | ; |
||
| 73 | $objectManagerMock |
||
| 74 | ->expects($this->any()) |
||
| 75 | ->method('flush') |
||
| 76 | ->willReturn(true) |
||
| 77 | ; |
||
| 78 | $objectManagerMock |
||
| 79 | ->expects($this->any()) |
||
| 80 | ->method('getRepository') |
||
| 81 | ->willReturnCallback([$this, 'getRepositoryMock']) |
||
| 82 | ; |
||
| 83 | return $objectManagerMock; |
||
| 84 | } |
||
| 85 | |||
| 86 | public function getRepositoryMock() |
||
| 87 | { |
||
| 88 | $repositoryMock = $this |
||
| 89 | ->getMockBuilder(\Scrumban\Repository\SprintRepository::class) |
||
| 90 | ->disableOriginalConstructor() |
||
| 91 | ->getMock() |
||
| 92 | ; |
||
| 93 | $repositoryMock |
||
| 94 | ->expects($this->any()) |
||
| 95 | ->method('getCurrentSprint') |
||
| 96 | ->willReturnCallback([$this, 'getSprintMock']) |
||
| 97 | ; |
||
| 98 | $repositoryMock |
||
| 99 | ->expects($this->any()) |
||
| 100 | ->method('getPreviousSprint') |
||
| 101 | ->willReturnCallback([$this, 'getSprintMock']) |
||
| 102 | ; |
||
| 103 | $repositoryMock |
||
| 104 | ->expects($this->any()) |
||
| 105 | ->method('find') |
||
| 106 | ->willReturnCallback([$this, 'getSprintMock']) |
||
| 107 | ; |
||
| 108 | $repositoryMock |
||
| 109 | ->expects($this->any()) |
||
| 110 | ->method('getSprintByPeriod') |
||
| 111 | ->willReturnCallback(function($beginDate) { |
||
| 112 | $sprint = $this->getSprintMock(3); |
||
| 113 | |||
| 114 | return ($beginDate < $sprint->getEndedAt()) ? [$sprint]: []; |
||
| 115 | }); |
||
| 116 | return $repositoryMock; |
||
| 117 | } |
||
| 118 | |||
| 119 | public function getSprintMock($id = null) |
||
| 120 | { |
||
| 121 | $sprint = |
||
| 122 | (new Sprint()) |
||
| 123 | ->setDemoUrl('http://example.org/demo.flv') |
||
| 124 | ->setBeginAt(new \DateTime('-3 days')) |
||
| 125 | ->setEndedAt(new \DateTime('+11 days')) |
||
| 126 | ; |
||
| 127 | if($id !== null) { |
||
| 128 | $sprint->setId($id); |
||
| 129 | } |
||
| 130 | return $sprint; |
||
| 131 | } |
||
| 132 | |||
| 133 | public function getEventDispatcherMock() |
||
| 134 | { |
||
| 135 | $dispatcherMock = $this->createMock(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class); |
||
| 136 | $dispatcherMock |
||
| 137 | ->expects($this->any()) |
||
| 138 | ->method('dispatch') |
||
| 139 | ->willReturn(true) |
||
| 140 | ; |
||
| 141 | return $dispatcherMock; |
||
| 142 | } |
||
| 143 | } |
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