function it_does_not_add_user_when_the_user_already_exists(AddUserCommand $command, UserRepository $repository, User $user) { $command->userId()->shouldBeCalled()->willReturn('user-id'); $repository->userOfId(UserId::generate('user-id'))->shouldBeCalled()->willReturn($user); $user->id()->shouldBeCalled()->willReturn(UserId::generate('user-id')); $this->shouldThrow(UserAlreadyExistsException::class)->during__invoke($command); }
function it_does_not_create_an_organization_because_user_does_not_exist(CreateOrganizationCommand $command, UserRepository $userRepository) { $command->id()->shouldBeCalled()->willReturn(null); $command->creatorId()->shouldBeCalled()->willReturn('user-id'); $userRepository->userOfId(Argument::type(UserId::class))->shouldBeCalled()->willReturn(null); $this->shouldThrow(UserDoesNotExistException::class)->during__invoke($command); }