private function parseMessages($data) { $messages = array(); foreach ($data as $row) { $message = $this->connection->getMessage($row['id']); $messages[] = $this->messageTransformer->transform($message); } return $messages; }
function it_should_return_messages_to_given_recipient(ConnectionInterface $connection, ArrayToMessageTransformer $messageTransformer) { $rawMessages = array(array('id' => 4, 'recipients' => array('*****@*****.**')), array('id' => 2, 'recipients' => array('*****@*****.**', '*****@*****.**')), array('id' => 1, 'recipients' => array('*****@*****.**'))); $prophet = new Prophet(); $mockMessages = array($prophet->prophesize('Kibao\\MailCatcher\\Message\\MessageInterface'), $prophet->prophesize('Kibao\\MailCatcher\\Message\\MessageInterface'), $prophet->prophesize('Kibao\\MailCatcher\\Message\\MessageInterface')); for ($i = 0; $i < 3; $i++) { $rawMessage = $rawMessages[$i]; $recipients = array(); foreach ($rawMessage['recipients'] as $email) { $recipient = $prophet->prophesize('Kibao\\MailCatcher\\Address\\AddressInterface'); $recipient->getEmail()->willReturn($email); $recipients[] = $recipient; } $mockMessages[$i]->getRecipients()->willReturn($recipients); $messageTransformer->transform($rawMessage)->willReturn($mockMessages[$i]); $connection->getMessage($rawMessage['id'])->willReturn($rawMessage); } $connection->getMessages()->willReturn($rawMessages); $this->getMessagesTo('*****@*****.**')->shouldReturn(array($mockMessages[0], $mockMessages[1])); $prophet->checkPredictions(); }