コード例 #1
0
 public function __invoke(RemoveOrganizationMemberToOrganizationCommand $command)
 {
     $organization = $this->repository->organizationOfId(OrganizationId::generate($command->organizationId()));
     if (!$organization instanceof Organization) {
         throw new OrganizationDoesNotExistException();
     }
     if (!$organization->isOwner(UserId::generate($command->removerId()))) {
         throw new UnauthorizedOrganizationActionException();
     }
     $organization->removeOrganizationMember(UserId::generate($command->userId()));
     $this->repository->persist($organization);
 }
 function it_removes_organization_member_to_organization(RemoveOrganizationMemberToOrganizationCommand $command, OrganizationRepository $repository, Organization $organization)
 {
     $organizationId = OrganizationId::generate('organization-id');
     $command->organizationId()->shouldBeCalled()->willReturn('organization-id');
     $repository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization);
     $command->removerId()->shouldBeCalled()->willReturn('remover-id');
     $organization->isOwner(UserId::generate('remover-id'))->shouldBeCalled()->willReturn(true);
     $command->userId()->shouldBeCalled()->willReturn('user-id');
     $organization->removeOrganizationMember(UserId::generate('user-id'))->shouldBeCalled();
     $repository->persist(Argument::type(Organization::class))->shouldBeCalled();
     $this->__invoke($command);
 }