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\Application\Query\Project\Task; |
14
|
|
|
|
15
|
|
|
use Kreta\TaskManager\Application\Query\Project\Task\CountTasksHandler; |
16
|
|
|
use Kreta\TaskManager\Application\Query\Project\Task\CountTasksQuery; |
17
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\Organization; |
18
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId; |
19
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationRepository; |
20
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Project; |
21
|
|
|
use Kreta\TaskManager\Domain\Model\Project\ProjectId; |
22
|
|
|
use Kreta\TaskManager\Domain\Model\Project\ProjectRepository; |
23
|
|
|
use Kreta\TaskManager\Domain\Model\Project\ProjectSpecificationFactory; |
24
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\Task; |
25
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskId; |
26
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskRepository; |
27
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\TaskSpecificationFactory; |
28
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Task\UnauthorizedTaskResourceException; |
29
|
|
|
use Kreta\TaskManager\Domain\Model\User\UserId; |
30
|
|
|
use PhpSpec\ObjectBehavior; |
31
|
|
|
use Prophecy\Argument; |
32
|
|
|
|
33
|
|
|
class CountTasksHandlerSpec extends ObjectBehavior |
34
|
|
|
{ |
35
|
|
|
function let( |
36
|
|
|
ProjectRepository $projectRepository, |
37
|
|
|
ProjectSpecificationFactory $projectSpecificationFactory, |
38
|
|
|
OrganizationRepository $organizationRepository, |
39
|
|
|
TaskRepository $repository, |
40
|
|
|
TaskSpecificationFactory $specificationFactory |
41
|
|
|
) { |
42
|
|
|
$this->beConstructedWith( |
43
|
|
|
$projectRepository, |
44
|
|
|
$projectSpecificationFactory, |
45
|
|
|
$organizationRepository, |
46
|
|
|
$repository, |
47
|
|
|
$specificationFactory |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function it_is_initializable() |
52
|
|
|
{ |
53
|
|
|
$this->shouldHaveType(CountTasksHandler::class); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
View Code Duplication |
function it_counts_tasks( |
|
|
|
|
57
|
|
|
CountTasksQuery $query, |
58
|
|
|
ProjectRepository $projectRepository, |
59
|
|
|
OrganizationRepository $organizationRepository, |
60
|
|
|
TaskRepository $repository, |
61
|
|
|
Organization $organization, |
62
|
|
|
Project $project, |
63
|
|
|
OrganizationId $organizationId, |
64
|
|
|
Task $parent, |
65
|
|
|
ProjectId $parentProjectId, |
66
|
|
|
Project $parentProject, |
67
|
|
|
OrganizationId $parentOrganizationId, |
68
|
|
|
Organization $parentOrganization, |
69
|
|
|
TaskId $parentId |
70
|
|
|
) { |
71
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
72
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
73
|
|
|
$projectRepository->projectOfId(ProjectId::generate('project-id')) |
74
|
|
|
->shouldBeCalled()->willReturn($project); |
75
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
76
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
77
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
78
|
|
|
$query->title()->shouldBeCalled()->willReturn('task title'); |
79
|
|
|
$query->parentId()->shouldBeCalled()->willReturn('parent-id'); |
80
|
|
|
|
81
|
|
|
$repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn($parent); |
82
|
|
|
$parent->projectId()->shouldBeCalled()->willReturn($parentProjectId); |
83
|
|
|
$projectRepository->projectOfId($parentProjectId)->shouldBeCalled()->willReturn($parentProject); |
84
|
|
|
$parentProject->organizationId()->shouldBeCalled()->willReturn($parentOrganizationId); |
85
|
|
|
$organizationRepository->organizationOfId($parentOrganizationId) |
86
|
|
|
->shouldBeCalled()->willReturn($parentOrganization); |
87
|
|
|
$parentOrganization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
88
|
|
|
$parent->id()->shouldBeCalled()->willReturn($parentId); |
89
|
|
|
|
90
|
|
|
$query->priority()->shouldBeCalled()->willReturn('low'); |
91
|
|
|
$query->progress()->shouldBeCalled()->willReturn('doing'); |
92
|
|
|
|
93
|
|
|
$repository->count(Argument::any())->shouldBeCalled()->willReturn(2); |
94
|
|
|
$this->__invoke($query)->shouldReturn(2); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
View Code Duplication |
function it_counts_without_task_title( |
|
|
|
|
98
|
|
|
CountTasksQuery $query, |
99
|
|
|
ProjectRepository $projectRepository, |
100
|
|
|
OrganizationRepository $organizationRepository, |
101
|
|
|
TaskRepository $repository, |
102
|
|
|
Organization $organization, |
103
|
|
|
Project $project, |
104
|
|
|
OrganizationId $organizationId, |
105
|
|
|
Task $parent, |
106
|
|
|
ProjectId $parentProjectId, |
107
|
|
|
Project $parentProject, |
108
|
|
|
OrganizationId $parentOrganizationId, |
109
|
|
|
Organization $parentOrganization, |
110
|
|
|
TaskId $parentId |
111
|
|
|
) { |
112
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
113
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
114
|
|
|
$projectRepository->projectOfId(ProjectId::generate('project-id')) |
115
|
|
|
->shouldBeCalled()->willReturn($project); |
116
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
117
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
118
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
119
|
|
|
$query->title()->shouldBeCalled(); |
120
|
|
|
$query->parentId()->shouldBeCalled()->willReturn('parent-id'); |
121
|
|
|
|
122
|
|
|
$repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn($parent); |
123
|
|
|
$parent->projectId()->shouldBeCalled()->willReturn($parentProjectId); |
124
|
|
|
$projectRepository->projectOfId($parentProjectId)->shouldBeCalled()->willReturn($parentProject); |
125
|
|
|
$parentProject->organizationId()->shouldBeCalled()->willReturn($parentOrganizationId); |
126
|
|
|
$organizationRepository->organizationOfId($parentOrganizationId) |
127
|
|
|
->shouldBeCalled()->willReturn($parentOrganization); |
128
|
|
|
$parentOrganization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
129
|
|
|
$parent->id()->shouldBeCalled()->willReturn($parentId); |
130
|
|
|
|
131
|
|
|
$query->priority()->shouldBeCalled()->willReturn('low'); |
132
|
|
|
$query->progress()->shouldBeCalled()->willReturn('doing'); |
133
|
|
|
|
134
|
|
|
$repository->count(Argument::any())->shouldBeCalled()->willReturn(3); |
135
|
|
|
$this->__invoke($query)->shouldReturn(3); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
function it_counts_tasks_without_parent_id( |
139
|
|
|
CountTasksQuery $query, |
140
|
|
|
ProjectRepository $projectRepository, |
141
|
|
|
OrganizationRepository $organizationRepository, |
142
|
|
|
TaskRepository $repository, |
143
|
|
|
Organization $organization, |
144
|
|
|
Project $project, |
145
|
|
|
OrganizationId $organizationId |
146
|
|
|
) { |
147
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
148
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
149
|
|
|
$projectRepository->projectOfId(ProjectId::generate('project-id')) |
150
|
|
|
->shouldBeCalled()->willReturn($project); |
151
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
152
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
153
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
154
|
|
|
$query->title()->shouldBeCalled()->willReturn('task title'); |
155
|
|
|
$query->parentId()->shouldBeCalled()->willReturn(null); |
156
|
|
|
|
157
|
|
|
$query->priority()->shouldBeCalled()->willReturn('low'); |
158
|
|
|
$query->progress()->shouldBeCalled()->willReturn('doing'); |
159
|
|
|
|
160
|
|
|
$repository->count(Argument::any())->shouldBeCalled()->willReturn(2); |
161
|
|
|
$this->__invoke($query)->shouldReturn(2); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
View Code Duplication |
function it_counts_without_project_id( |
|
|
|
|
165
|
|
|
CountTasksQuery $query, |
166
|
|
|
ProjectRepository $projectRepository, |
167
|
|
|
OrganizationRepository $organizationRepository, |
168
|
|
|
TaskRepository $repository, |
169
|
|
|
Organization $organization, |
170
|
|
|
Project $project, |
171
|
|
|
OrganizationId $organizationId, |
172
|
|
|
Task $parent, |
173
|
|
|
ProjectId $parentProjectId, |
174
|
|
|
Project $parentProject, |
175
|
|
|
OrganizationId $parentOrganizationId, |
176
|
|
|
Organization $parentOrganization, |
177
|
|
|
TaskId $parentId |
178
|
|
|
) { |
179
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
180
|
|
|
$query->projectId()->shouldBeCalled(); |
181
|
|
|
$projectRepository->projectOfId(Argument::type(ProjectId::class)) |
182
|
|
|
->shouldBeCalled()->willReturn($project); |
183
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
184
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
185
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
186
|
|
|
$query->title()->shouldBeCalled()->willReturn('task title'); |
187
|
|
|
|
188
|
|
|
$query->parentId()->shouldBeCalled()->willReturn('parent-id'); |
189
|
|
|
|
190
|
|
|
$repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn($parent); |
191
|
|
|
$parent->projectId()->shouldBeCalled()->willReturn($parentProjectId); |
192
|
|
|
$projectRepository->projectOfId($parentProjectId)->shouldBeCalled()->willReturn($parentProject); |
193
|
|
|
$parentProject->organizationId()->shouldBeCalled()->willReturn($parentOrganizationId); |
194
|
|
|
$organizationRepository->organizationOfId($parentOrganizationId) |
195
|
|
|
->shouldBeCalled()->willReturn($parentOrganization); |
196
|
|
|
$parentOrganization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
197
|
|
|
$parent->id()->shouldBeCalled()->willReturn($parentId); |
198
|
|
|
|
199
|
|
|
$query->priority()->shouldBeCalled()->willReturn('low'); |
200
|
|
|
$query->progress()->shouldBeCalled()->willReturn('doing'); |
201
|
|
|
|
202
|
|
|
$repository->count(Argument::any())->shouldBeCalled()->willReturn(3); |
203
|
|
|
$this->__invoke($query)->shouldReturn(3); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
View Code Duplication |
function it_counts_tasks_without_priority( |
|
|
|
|
207
|
|
|
CountTasksQuery $query, |
208
|
|
|
ProjectRepository $projectRepository, |
209
|
|
|
OrganizationRepository $organizationRepository, |
210
|
|
|
TaskRepository $repository, |
211
|
|
|
Organization $organization, |
212
|
|
|
Project $project, |
213
|
|
|
OrganizationId $organizationId, |
214
|
|
|
Task $parent, |
215
|
|
|
ProjectId $parentProjectId, |
216
|
|
|
Project $parentProject, |
217
|
|
|
OrganizationId $parentOrganizationId, |
218
|
|
|
Organization $parentOrganization, |
219
|
|
|
TaskId $parentId |
220
|
|
|
) { |
221
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
222
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
223
|
|
|
$projectRepository->projectOfId(ProjectId::generate('project-id')) |
224
|
|
|
->shouldBeCalled()->willReturn($project); |
225
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
226
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
227
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
228
|
|
|
$query->title()->shouldBeCalled()->willReturn('task title'); |
229
|
|
|
$query->parentId()->shouldBeCalled()->willReturn('parent-id'); |
230
|
|
|
|
231
|
|
|
$repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn($parent); |
232
|
|
|
$parent->projectId()->shouldBeCalled()->willReturn($parentProjectId); |
233
|
|
|
$projectRepository->projectOfId($parentProjectId)->shouldBeCalled()->willReturn($parentProject); |
234
|
|
|
$parentProject->organizationId()->shouldBeCalled()->willReturn($parentOrganizationId); |
235
|
|
|
$organizationRepository->organizationOfId($parentOrganizationId) |
236
|
|
|
->shouldBeCalled()->willReturn($parentOrganization); |
237
|
|
|
$parentOrganization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
238
|
|
|
$parent->id()->shouldBeCalled()->willReturn($parentId); |
239
|
|
|
|
240
|
|
|
$query->priority()->shouldBeCalled()->willReturn(null); |
241
|
|
|
$query->progress()->shouldBeCalled()->willReturn('doing'); |
242
|
|
|
|
243
|
|
|
$repository->count(Argument::any())->shouldBeCalled()->willReturn(2); |
244
|
|
|
$this->__invoke($query)->shouldReturn(2); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
View Code Duplication |
function it_counts_tasks_without_progress( |
|
|
|
|
248
|
|
|
CountTasksQuery $query, |
249
|
|
|
ProjectRepository $projectRepository, |
250
|
|
|
OrganizationRepository $organizationRepository, |
251
|
|
|
TaskRepository $repository, |
252
|
|
|
Organization $organization, |
253
|
|
|
Project $project, |
254
|
|
|
OrganizationId $organizationId, |
255
|
|
|
Task $parent, |
256
|
|
|
ProjectId $parentProjectId, |
257
|
|
|
Project $parentProject, |
258
|
|
|
OrganizationId $parentOrganizationId, |
259
|
|
|
Organization $parentOrganization, |
260
|
|
|
TaskId $parentId |
261
|
|
|
) { |
262
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
263
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
264
|
|
|
$projectRepository->projectOfId(ProjectId::generate('project-id')) |
265
|
|
|
->shouldBeCalled()->willReturn($project); |
266
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
267
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
268
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
269
|
|
|
$query->title()->shouldBeCalled()->willReturn('task title'); |
270
|
|
|
$query->parentId()->shouldBeCalled()->willReturn('parent-id'); |
271
|
|
|
|
272
|
|
|
$repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn($parent); |
273
|
|
|
$parent->projectId()->shouldBeCalled()->willReturn($parentProjectId); |
274
|
|
|
$projectRepository->projectOfId($parentProjectId)->shouldBeCalled()->willReturn($parentProject); |
275
|
|
|
$parentProject->organizationId()->shouldBeCalled()->willReturn($parentOrganizationId); |
276
|
|
|
$organizationRepository->organizationOfId($parentOrganizationId) |
277
|
|
|
->shouldBeCalled()->willReturn($parentOrganization); |
278
|
|
|
$parentOrganization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
279
|
|
|
$parent->id()->shouldBeCalled()->willReturn($parentId); |
280
|
|
|
|
281
|
|
|
$query->priority()->shouldBeCalled()->willReturn('low'); |
282
|
|
|
$query->progress()->shouldBeCalled()->willReturn(null); |
283
|
|
|
|
284
|
|
|
$repository->count(Argument::any())->shouldBeCalled()->willReturn(2); |
285
|
|
|
$this->__invoke($query)->shouldReturn(2); |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
function it_counts_with_does_not_exist_parent_task( |
289
|
|
|
CountTasksQuery $query, |
290
|
|
|
ProjectRepository $projectRepository, |
291
|
|
|
OrganizationRepository $organizationRepository, |
292
|
|
|
TaskRepository $repository, |
293
|
|
|
Organization $organization, |
294
|
|
|
Project $project, |
295
|
|
|
OrganizationId $organizationId |
296
|
|
|
) { |
297
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
298
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
299
|
|
|
$projectRepository->projectOfId(ProjectId::generate('project-id')) |
300
|
|
|
->shouldBeCalled()->willReturn($project); |
301
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
302
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
303
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
304
|
|
|
$query->title()->shouldBeCalled()->willReturn('task title'); |
305
|
|
|
$query->parentId()->shouldBeCalled()->willReturn('parent-id'); |
306
|
|
|
|
307
|
|
|
$repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn(null); |
308
|
|
|
|
309
|
|
|
$query->priority()->shouldBeCalled()->willReturn('low'); |
310
|
|
|
$query->progress()->shouldBeCalled()->willReturn('doing'); |
311
|
|
|
|
312
|
|
|
$repository->count(Argument::any())->shouldBeCalled()->willReturn(2); |
313
|
|
|
$this->__invoke($query)->shouldReturn(2); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
View Code Duplication |
function it_does_not_count_when_user_does_not_allow_to_perform_this_action( |
|
|
|
|
317
|
|
|
CountTasksQuery $query, |
318
|
|
|
ProjectRepository $projectRepository, |
319
|
|
|
OrganizationRepository $organizationRepository, |
320
|
|
|
Organization $organization, |
321
|
|
|
Project $project, |
322
|
|
|
OrganizationId $organizationId |
323
|
|
|
) { |
324
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
325
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
326
|
|
|
$projectRepository->projectOfId(Argument::type(ProjectId::class)) |
327
|
|
|
->shouldBeCalled()->willReturn($project); |
328
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
329
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
330
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(false); |
331
|
|
|
$this->shouldThrow(UnauthorizedTaskResourceException::class)->during__invoke($query); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
View Code Duplication |
function it_does_not_count_when_user_does_not_allow_to_perform_parent_task_action( |
|
|
|
|
335
|
|
|
CountTasksQuery $query, |
336
|
|
|
ProjectRepository $projectRepository, |
337
|
|
|
OrganizationRepository $organizationRepository, |
338
|
|
|
TaskRepository $repository, |
339
|
|
|
Organization $organization, |
340
|
|
|
Project $project, |
341
|
|
|
OrganizationId $organizationId, |
342
|
|
|
Task $parent, |
343
|
|
|
ProjectId $parentProjectId, |
344
|
|
|
Project $parentProject, |
345
|
|
|
OrganizationId $parentOrganizationId, |
346
|
|
|
Organization $parentOrganization |
347
|
|
|
) { |
348
|
|
|
$query->userId()->shouldBeCalled()->willReturn('user-id'); |
349
|
|
|
$query->projectId()->shouldBeCalled()->willReturn('project-id'); |
350
|
|
|
$projectRepository->projectOfId(ProjectId::generate('project-id')) |
351
|
|
|
->shouldBeCalled()->willReturn($project); |
352
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
353
|
|
|
$organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
354
|
|
|
$organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(true); |
355
|
|
|
$query->title()->shouldBeCalled()->willReturn('task title'); |
356
|
|
|
$query->parentId()->shouldBeCalled()->willReturn('parent-id'); |
357
|
|
|
|
358
|
|
|
$repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn($parent); |
359
|
|
|
$parent->projectId()->shouldBeCalled()->willReturn($parentProjectId); |
360
|
|
|
$projectRepository->projectOfId($parentProjectId)->shouldBeCalled()->willReturn($parentProject); |
361
|
|
|
$parentProject->organizationId()->shouldBeCalled()->willReturn($parentOrganizationId); |
362
|
|
|
$organizationRepository->organizationOfId($parentOrganizationId) |
363
|
|
|
->shouldBeCalled()->willReturn($parentOrganization); |
364
|
|
|
$parentOrganization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(false); |
365
|
|
|
$this->shouldThrow(UnauthorizedTaskResourceException::class)->during__invoke($query); |
366
|
|
|
} |
367
|
|
|
} |
368
|
|
|
|
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.