Exemple #1
0
 public function __invoke(EditTaskCommand $command)
 {
     $task = $this->repository->taskOfId(TaskId::generate($command->id()));
     if (!$task instanceof Task) {
         throw new TaskDoesNotExistException();
     }
     $project = $this->projectRepository->projectOfId($task->projectId());
     $organization = $this->organizationRepository->organizationOfId($project->organizationId());
     if (!$organization->isOrganizationMember(UserId::generate($command->editorId()))) {
         throw new UnauthorizedTaskActionException();
     }
     $task->edit(new TaskTitle($command->title()), $command->description());
     $this->repository->persist($task);
 }
Exemple #2
0
 function it_edits_an_task(EditTaskCommand $command, TaskRepository $repository, Task $task, ProjectRepository $projectRepository, OrganizationRepository $organizationRepository, ProjectId $projectId, Project $project, OrganizationId $organizationId, Organization $organization)
 {
     $command->id()->shouldBeCalled()->willReturn('task-id');
     $repository->taskOfId(TaskId::generate('task-id'))->shouldBeCalled()->willReturn($task);
     $task->projectId()->shouldBeCalled()->willReturn($projectId);
     $projectRepository->projectOfId($projectId)->shouldBeCalled()->willReturn($project);
     $project->organizationId()->shouldBeCalled()->willReturn($organizationId);
     $organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization);
     $command->editorId()->shouldBeCalled()->willReturn('editor-id');
     $organization->isOrganizationMember(UserId::generate('editor-id'))->shouldBeCalled()->willReturn(true);
     $command->title()->shouldBeCalled()->willReturn('Task title');
     $command->description()->shouldBeCalled()->willReturn('Task description');
     $task->edit(new TaskTitle('Task title'), 'Task description')->shouldBeCalled();
     $repository->persist(Argument::type(Task::class))->shouldBeCalled();
     $this->__invoke($command);
 }