1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Kreta package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace Spec\Kreta\TaskManager\Domain\Model\Project\Task; |
16
|
|
|
|
17
|
|
|
use Kreta\SharedKernel\Domain\Model\DomainEvent; |
18
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\MemberId; |
19
|
|
|
use Kreta\TaskManager\Domain\Model\Project\ProjectId; |
20
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\NumericId; |
21
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskCreated; |
22
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskId; |
23
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskPriority; |
24
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskTitle; |
25
|
|
|
use PhpSpec\ObjectBehavior; |
26
|
|
|
|
27
|
|
|
class TaskCreatedSpec extends ObjectBehavior |
28
|
|
|
{ |
29
|
|
View Code Duplication |
function let( |
|
|
|
|
30
|
|
|
TaskId $taskId, |
31
|
|
|
NumericId $numericId, |
32
|
|
|
TaskTitle $title, |
33
|
|
|
MemberId $creatorId, |
34
|
|
|
MemberId $assigneeId, |
35
|
|
|
TaskPriority $priority, |
36
|
|
|
ProjectId $projectId, |
37
|
|
|
TaskId $parentId |
38
|
|
|
) { |
39
|
|
|
$this->beConstructedWith( |
40
|
|
|
$taskId, |
41
|
|
|
$numericId, |
42
|
|
|
$title, |
43
|
|
|
'Description', |
44
|
|
|
$creatorId, |
45
|
|
|
$assigneeId, |
46
|
|
|
$priority, |
47
|
|
|
$projectId, |
48
|
|
|
$parentId |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
function it_creates_a_task_created_event( |
53
|
|
|
TaskId $taskId, |
54
|
|
|
NumericId $numericId, |
55
|
|
|
TaskTitle $title, |
56
|
|
|
MemberId $creatorId, |
57
|
|
|
MemberId $assigneeId, |
58
|
|
|
TaskPriority $priority, |
59
|
|
|
ProjectId $projectId, |
60
|
|
|
TaskId $parentId |
61
|
|
|
) { |
62
|
|
|
$this->shouldHaveType(TaskCreated::class); |
63
|
|
|
$this->shouldImplement(DomainEvent::class); |
64
|
|
|
|
65
|
|
|
$this->id()->shouldReturn($taskId); |
66
|
|
|
$this->numericId()->shouldReturn($numericId); |
67
|
|
|
$this->title()->shouldReturn($title); |
68
|
|
|
$this->description()->shouldReturn('Description'); |
69
|
|
|
$this->creatorId()->shouldReturn($creatorId); |
70
|
|
|
$this->assigneeId()->shouldReturn($assigneeId); |
71
|
|
|
$this->priority()->shouldReturn($priority); |
72
|
|
|
$this->projectId()->shouldReturn($projectId); |
73
|
|
|
$this->parentId()->shouldReturn($parentId); |
74
|
|
|
$this->occurredOn()->shouldReturnAnInstanceOf(\DateTimeInterface::class); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.