/**
  * @param \Wonderland\Application\Model\Member $author
  * @return array
  */
 public function getSentMessages(Member $author)
 {
     $statement = $this->repository->findByAuthor($author);
     $messages = [];
     while ($data = $statement->fetch(\PDO::FETCH_ASSOC)) {
         $recipient = $this->memberManager->getMember($data['recipient_id']);
         $messages[] = (new Message())->setId($data['id'])->setTitle($data['title'])->setContent($data['content'])->setAuthor($author)->setRecipient($recipient)->setCreatedAt(new \DateTime($data['created_at']));
     }
     return $messages;
 }
 public function findByAuthor()
 {
     $messages = $this->repository->findByAuthor((new Member())->setId(1)->setIdentity('John Doe')->setAvatar('avatar.png'));
     $this->assertCount(1, $messages);
     $message = $messages[0];
     $this->assertInstanceOf('Wonderland\\Application\\Model\\Message', $message);
     $this->assertEquals(1, $message->getId());
     $this->assertEquals('Test', $message->getTitle());
     $this->assertEquals('test', $message->getContent());
     $this->assertNull($message->getOpenedAt());
     $this->assertInstanceOf('DateTime', $message->getCreateAt());
     $author = $message->getAuthor();
     $this->assertInstanceOf('Wonderland\\Application\\Model\\Member', $author);
     $this->assertEquals(2, $author->getId());
     $this->assertEquals('Alexander', $author->getIdentity());
     $this->assertEquals('avatar.jpg', $author->getAvatar());
     $recipient = $message->getRecipient();
     $this->assertInstanceOf('Wonderland\\Application\\Model\\Member', $recipient);
     $this->assertEquals(2, $recipient->getId());
     $this->assertEquals('Alexander', $recipient->getIdentity());
     $this->assertEquals('avatar.jpg', $recipient->getAvatar());
 }
 /**
  * @param \Wonderland\Application\Model\Member $author
  *
  * @return array
  */
 public function getSentMessages(Member $author)
 {
     return $this->repository->findByAuthor($author);
 }