コード例 #1
0
 function it_counts_organizations(CountOrganizationsQuery $query, OrganizationRepository $repository)
 {
     $query->name()->shouldBeCalled()->willReturn('organization name');
     $query->userId()->shouldBeCalled()->willReturn('user-id');
     $repository->count(Argument::any())->shouldBeCalled()->willReturn(2);
     $this->__invoke($query)->shouldReturn(2);
 }
コード例 #2
0
 function it_does_not_serialize_organization_member_because_it_does_not_exist(OrganizationMemberOfIdQuery $query, OrganizationRepository $repository, Organization $organization)
 {
     $query->organizationId()->shouldBeCalled()->willReturn('organization-id');
     $repository->organizationOfId(OrganizationId::generate('organization-id'))->shouldBeCalled()->willReturn($organization);
     $query->userId()->shouldBeCalled()->willReturn('user-id');
     $organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(OrganizationMemberDoesNotExistException::class)->during__invoke($query);
 }
コード例 #3
0
 function it_does_not_edits_an_organization_because_the_owner_does_not_authorized(EditOrganizationCommand $command, OrganizationRepository $repository, Organization $organization)
 {
     $command->id()->shouldBeCalled()->willReturn('organization-id');
     $repository->organizationOfId(OrganizationId::generate('organization-id'))->shouldBeCalled()->willReturn($organization);
     $command->userId()->shouldBeCalled()->willReturn('editor-id');
     $organization->isOwner(UserId::generate('editor-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedEditOrganizationException::class)->during__invoke($command);
 }
コード例 #4
0
 function it_does_not_add_organization_member_to_organization_because_it_is_not_allowed(AddOrganizationMemberToOrganizationCommand $command, OrganizationRepository $repository, Organization $organization)
 {
     $organizationId = OrganizationId::generate('organization-id');
     $command->organizationId()->shouldBeCalled()->willReturn('organization-id');
     $repository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization);
     $command->adderId()->shouldBeCalled()->willReturn('adder-id');
     $organization->isOwner(UserId::generate('adder-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedOrganizationActionException::class)->during__invoke($command);
 }
コード例 #5
0
 function it_does_not_serialize_project_when_the_user_does_not_allowed(ProjectOfIdQuery $query, ProjectRepository $repository, Project $project, OrganizationId $organizationId, OrganizationRepository $organizationRepository, Organization $organization)
 {
     $query->projectId()->shouldBeCalled()->willReturn('project-id');
     $repository->projectOfId(ProjectId::generate('project-id'))->shouldBeCalled()->willReturn($project);
     $project->organizationId()->shouldBeCalled()->willReturn($organizationId);
     $organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization);
     $query->userId()->shouldBeCalled()->willReturn('user-id');
     $organization->isOrganizationMember(UserId::generate('user-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedProjectResourceException::class)->during__invoke($query);
 }
コード例 #6
0
 function it_serializes_filtered_organizations(FilterOrganizationsQuery $query, OrganizationRepository $repository, Organization $organization, OrganizationDataTransformer $dataTransformer)
 {
     $query->userId()->shouldBeCalled()->willReturn('user-id');
     $query->name()->shouldBeCalled()->willReturn('organization name');
     $query->offset()->shouldBeCalled()->willReturn(0);
     $query->limit()->shouldBeCalled()->willReturn(-1);
     $repository->query(Argument::any())->shouldBeCalled()->willReturn([$organization]);
     $dataTransformer->write($organization)->shouldBeCalled();
     $dataTransformer->read()->shouldBeCalled();
     $this->__invoke($query)->shouldBeArray();
 }
コード例 #7
0
ファイル: EditTaskHandlerSpec.php プロジェクト: kreta/kreta
 function it_does_not_edit_a_task_because_task_edition_is_not_allowed(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(false);
     $this->shouldThrow(UnauthorizedTaskActionException::class)->during__invoke($command);
 }
コード例 #8
0
 function it_does_not_allow_to_edit_project_if_editor_is_not_organization_owner(OrganizationRepository $organizationRepository, ProjectRepository $projectRepository, EditProjectCommand $command, Project $project, Organization $organization, OrganizationId $organizationId)
 {
     $command->id()->willReturn('project-id');
     $command->name()->willReturn('Project name');
     $command->slug()->willReturn(null);
     $command->editorId()->willReturn('editor-id');
     $projectRepository->projectOfId(ProjectId::generate('project-id'))->shouldBeCalled()->willReturn($project);
     $project->organizationId()->shouldBeCalled()->willReturn($organizationId);
     $organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization);
     $organization->isOwner(UserId::generate('editor-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedProjectActionException::class)->during__invoke($command);
 }
コード例 #9
0
 function it_does_not_allow_changing_priority_if_editor_is_not_organization_organizationMember(OrganizationRepository $organizationRepository, ProjectRepository $projectRepository, TaskRepository $taskRepository, ChangeTaskPriorityCommand $command, Task $task, Project $project, ProjectId $projectId, OrganizationId $organizationId, Organization $organization)
 {
     $command->id()->shouldBeCalled()->willReturn('task-id');
     $command->editorId()->shouldBeCalled()->willReturn('editor-id');
     $taskRepository->taskOfId(Argument::type(TaskId::class))->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);
     $organization->isOrganizationMember(UserId::generate('editor-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedTaskActionException::class)->during('__invoke', [$command]);
 }
コード例 #10
0
 function it_does_not_allow_to_reassign_when_editor_is_not_a_organization_organizationMember(OrganizationRepository $organizationRepository, ProjectRepository $projectRepository, TaskRepository $taskRepository, ReassignTaskCommand $command, Task $task, ProjectId $projectId, Project $project, OrganizationId $organizationId, Organization $organization)
 {
     $command->id()->shouldBeCalled()->willReturn('task-id');
     $command->assigneeId()->shouldBeCalled()->willReturn('new-assignee-id');
     $command->editorId()->shouldBeCalled()->willReturn('editor-id');
     $taskRepository->taskOfId(Argument::type(TaskId::class))->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);
     $organization->isOrganizationMember(UserId::generate('editor-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedTaskActionException::class)->during__invoke($command);
 }
コード例 #11
0
 function it_handles_task_priority_change(OrganizationRepository $organizationRepository, ProjectRepository $projectRepository, TaskRepository $taskRepository, ChangeTaskProgressCommand $command, Task $task, Project $project, ProjectId $projectId, OrganizationId $organizationId, Organization $organization)
 {
     $command->id()->shouldBeCalled()->willReturn('task-id');
     $command->progress()->shouldBeCalled()->willReturn('doing');
     $command->editorId()->shouldBeCalled()->willReturn('editor-id');
     $taskRepository->taskOfId(Argument::type(TaskId::class))->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);
     $organization->isOrganizationMember(UserId::generate('editor-id'))->shouldBeCalled()->willReturn(true);
     $task->changeProgress(Argument::type(TaskProgress::class))->shouldBeCalled();
     $taskRepository->persist(Argument::type(Task::class))->shouldBeCalled();
     $this->__invoke($command);
 }
コード例 #12
0
 function it_does_not_allow_to_create_project_if_creator_is_not_organization_owner(OrganizationRepository $organizationRepository, ProjectRepository $projectRepository, CreateProjectCommand $command, Organization $organization)
 {
     $command->id()->willReturn('project-id');
     $command->organizationId()->willReturn('organization-id');
     $command->creatorId()->willReturn('creator-id');
     $projectRepository->projectOfId(Argument::type(ProjectId::class))->shouldBeCalled()->willReturn(null);
     $organizationRepository->organizationOfId(Argument::type(OrganizationId::class))->shouldBeCalled()->willReturn($organization);
     $organization->isOwner(UserId::generate('creator-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedCreateProjectException::class)->during('__invoke', [$command]);
 }
コード例 #13
0
 function it_does_not_change_parent_task_because_task_action_is_not_allowed(ChangeParentTaskCommand $command, TaskRepository $repository, Task $task, TaskId $taskId, Task $parent, ProjectId $projectId, ProjectRepository $projectRepository, Project $project, OrganizationRepository $organizationRepository, Organization $organization, OrganizationId $organizationId)
 {
     $command->id()->shouldBeCalled()->willReturn('task-id');
     $repository->taskOfId(TaskId::generate('task-id'))->shouldBeCalled()->willReturn($task);
     $command->parentId()->shouldBeCalled()->willReturn('parent-id');
     $task->id()->shouldBeCalled()->willReturn($taskId);
     $taskId->equals(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn(false);
     $repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn($parent);
     $task->projectId()->shouldBeCalled()->willReturn($projectId);
     $parent->projectId()->shouldBeCalled()->willReturn($projectId);
     $projectId->equals($projectId)->shouldBeCalled()->willReturn(true);
     $projectRepository->projectOfId($projectId)->shouldBeCalled()->willReturn($project);
     $project->organizationId()->shouldBeCalled()->willReturn($organizationId);
     $organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization);
     $command->changerId()->shouldBeCalled()->willReturn('changer-id');
     $organization->isOrganizationMember(UserId::generate('changer-id'))->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(UnauthorizedTaskActionException::class)->during__invoke($command);
 }
コード例 #14
0
ファイル: CreateTaskHandlerSpec.php プロジェクト: kreta/kreta
 function it_does_not_create_a_task_because_parent_task_does_not_exist(CreateTaskCommand $command, TaskRepository $repository, ProjectRepository $projectRepository, OrganizationRepository $organizationRepository, Project $project, OrganizationId $organizationId, Organization $organization)
 {
     $command->projectId()->shouldBeCalled()->willReturn('project-id');
     $command->taskId()->shouldBeCalled()->willReturn('task-id');
     $command->parentId()->shouldBeCalled()->willReturn('parent-id');
     $repository->taskOfId(TaskId::generate('task-id'))->shouldBeCalled()->willReturn(null);
     $projectRepository->projectOfId(ProjectId::generate('project-id'))->shouldBeCalled()->willReturn($project);
     $project->organizationId()->shouldBeCalled()->willReturn($organizationId);
     $organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization);
     $command->creatorId()->shouldBeCalled()->willReturn('creator-id');
     $command->assigneeId()->shouldBeCalled()->willReturn('assignee-id');
     $organization->isOrganizationMember(UserId::generate('creator-id'))->shouldBeCalled()->willReturn(true);
     $organization->isOrganizationMember(UserId::generate('assignee-id'))->shouldBeCalled()->willReturn(true);
     $repository->taskOfId(TaskId::generate('parent-id'))->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(TaskParentDoesNotExistException::class)->during__invoke($command);
 }
コード例 #15
0
 function it_does_not_create_an_organization_because_already_exists_an_organization_with_id(CreateOrganizationCommand $command, OrganizationRepository $repository, Organization $organization)
 {
     $command->id()->shouldBeCalled()->willReturn('organization-id');
     $repository->organizationOfId(Argument::type(OrganizationId::class))->shouldBeCalled()->willReturn($organization);
     $this->shouldThrow(OrganizationAlreadyExistsException::class)->during__invoke($command);
 }
コード例 #16
0
 function it_does_not_serialize_organization_because_the_organization_does_not_exist(OrganizationOfIdQuery $query, OrganizationRepository $repository)
 {
     $query->organizationId()->shouldBeCalled()->willReturn('organization-id');
     $repository->organizationOfId(OrganizationId::generate('organization-id'))->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(OrganizationDoesNotExistException::class)->during__invoke($query);
 }