public function execute(Command $command, Responder $responder) { $user = $this->userRepository->getRandomActiveUser(); $message = $this->messageRepository->getRandomMessageForUser($user); $this->slackNotifier->send($message); $responder->userSuccessfullyPoked(); }
function it_should_retrieve_a_random_message_for_a_random_user_and_poke_him(MessageRepository $messageRepository, UserRepository $userRepository, SlackNotifier $slackNotifier, Responder $responder) { $userRepository->getRandomActiveUser()->willReturn($user = new User('id1', 'johndoe')); $messageRepository->getRandomMessageForUser($user)->willReturn($message = new Message('Test message')); $slackNotifier->send($message)->shouldBeCalled(); $responder->userSuccessfullyPoked()->shouldBeCalled(); $this->execute(new Command(), $responder); }