|
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
|
|
|
namespace Spec\Kreta\TaskManager\Domain\Model\Project\Task; |
|
14
|
|
|
|
|
15
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\Task; |
|
16
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskId; |
|
17
|
|
|
use PhpSpec\ObjectBehavior; |
|
18
|
|
|
|
|
19
|
|
|
class TaskSpec extends ObjectBehavior |
|
20
|
|
|
{ |
|
21
|
|
|
function let(TaskId $taskId, ProjectMemberId $creator, ProjectMemberId $assignee) |
|
22
|
|
|
{ |
|
23
|
|
|
$taskId->id()->willReturn('task-id'); |
|
24
|
|
|
$this->beConstructedWith($taskId, 'Title', 'Description', $creator, $assignee, Task::PRIORITY_LOW); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
function it_can_be_created(TaskId $taskId, ProjectMemberId $creator, ProjectMemberId $assignee) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->shouldHaveType(Task::class); |
|
30
|
|
|
$this->id()->shouldReturn($taskId); |
|
31
|
|
|
$this->title()->shouldReturn('Title'); |
|
32
|
|
|
$this->description()->shouldReturn('Description'); |
|
33
|
|
|
$this->creator()->shouldReturn($creator); |
|
34
|
|
|
$this->assignee()->shouldReturn($assignee); |
|
35
|
|
|
$this->priority()->shouldReturn(Task::PRIORITY_LOW); |
|
36
|
|
|
$this->parentId()->shouldReturn(null); |
|
37
|
|
|
|
|
38
|
|
|
$this->shouldBeTodo(); |
|
39
|
|
|
$this->shouldNotBeDoing(); |
|
40
|
|
|
$this->shouldNotBeDone(); |
|
41
|
|
|
|
|
42
|
|
|
$this->__toString()->shouldReturn('task-id'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function it_can_be_created_as_a_subtask(TaskId $taskId, |
|
46
|
|
|
ProjectMemberId $creator, |
|
47
|
|
|
ProjectMemberId $assignee, |
|
48
|
|
|
TaskId $parentId) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->beConstructedWith($taskId, 'Title', 'Description', $creator, $assignee, Task::PRIORITY_LOW, $parentId); |
|
51
|
|
|
$this->shouldHaveType(Task::class); |
|
52
|
|
|
$this->id()->shouldReturn($taskId); |
|
53
|
|
|
$this->title()->shouldReturn('Title'); |
|
54
|
|
|
$this->description()->shouldReturn('Description'); |
|
55
|
|
|
$this->creator()->shouldReturn($creator); |
|
56
|
|
|
$this->assignee()->shouldReturn($assignee); |
|
57
|
|
|
$this->priority()->shouldReturn(Task::PRIORITY_LOW); |
|
58
|
|
|
$this->parentId()->shouldReturn($parentId); |
|
59
|
|
|
|
|
60
|
|
|
$this->shouldBeTodo(); |
|
61
|
|
|
$this->shouldNotBeDoing(); |
|
62
|
|
|
$this->shouldNotBeDone(); |
|
63
|
|
|
|
|
64
|
|
|
$this->shouldHavePublished(TaskCreated::class); |
|
65
|
|
|
|
|
66
|
|
|
$this->__toString()->shouldReturn('task-id'); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
function it_can_be_edited() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->edit('New title', 'New description'); |
|
72
|
|
|
|
|
73
|
|
|
$this->title()->shouldReturn('New title'); |
|
74
|
|
|
$this->description()->shouldReturn('New description'); |
|
75
|
|
|
|
|
76
|
|
|
$this->shouldHavePublished(TaskEdited::class); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
function it_can_be_started() |
|
80
|
|
|
{ |
|
81
|
|
|
$this->start(); |
|
82
|
|
|
|
|
83
|
|
|
$this->shouldNotBeTodo(); |
|
84
|
|
|
$this->shouldBeDoing(); |
|
85
|
|
|
$this->shouldNotBeDone(); |
|
86
|
|
|
|
|
87
|
|
|
$this->shouldHavePublished(TaskStarted::class); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
function it_can_be_stopped() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->stop(); |
|
93
|
|
|
|
|
94
|
|
|
$this->shouldBeTodo(); |
|
95
|
|
|
$this->shouldNotBeDoing(); |
|
96
|
|
|
$this->shouldNotBeDone(); |
|
97
|
|
|
|
|
98
|
|
|
$this->shouldHavePublished(TaskStopped::class); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
function it_can_be_finished() |
|
102
|
|
|
{ |
|
103
|
|
|
$this->finish(); |
|
104
|
|
|
|
|
105
|
|
|
$this->shouldNotBeTodo(); |
|
106
|
|
|
$this->shouldNotBeDoing(); |
|
107
|
|
|
$this->shouldBeDone(); |
|
108
|
|
|
|
|
109
|
|
|
$this->shouldHavePublished(TaskFinished::class); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
function it_can_be_reassigned(ProjectMemberId $assignee) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->reassign($assignee); |
|
115
|
|
|
|
|
116
|
|
|
$this->assignee($assignee); |
|
117
|
|
|
|
|
118
|
|
|
$this->shouldHavePublished(TaskReassigned::class); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
function its_priority_can_be_changed() |
|
122
|
|
|
{ |
|
123
|
|
|
$this->changePriority(Task::PRIORITY_HIGH); |
|
124
|
|
|
|
|
125
|
|
|
$this->priority()->shouldReturn(Task::PRIORITY_HIGH); |
|
126
|
|
|
|
|
127
|
|
|
$this->shouldHavePublished(TaskPriorityChanged::class); |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|