function it_does_not_remove_owner_to_organization_because_it_is_not_allowed(RemoveOwnerToOrganizationCommand $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(false);
     $this->shouldThrow(UnauthorizedOrganizationActionException::class)->during__invoke($command);
 }
 public function __invoke(RemoveOwnerToOrganizationCommand $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->removeOwner(UserId::generate($command->userId()));
     $this->repository->persist($organization);
 }