Пример #1
0
 /**
  * @param  UserInterface $user
  * @return ConversationInterface[]
  */
 public function getUnreadConversations(UserInterface $user)
 {
     $unreadConversationReceivers = $this->pmMapper->getUnreadConversationReceivers($user);
     $unreadConversations = [];
     foreach ($unreadConversationReceivers as $receive) {
         $unreadConversations[] = $receive->getConversation();
     }
     $this->getEventManager()->trigger('getUnreadConversations', $this, ['unreadConversations' => $unreadConversations]);
     return $unreadConversations;
 }
 /**
  * @covers Eye4web\ZfcUser\Pm\Service\PmService::getUnreadConversations
  */
 public function testGetUnreadConversations()
 {
     $user = new User();
     $user->setId(1);
     $conversation1 = new Conversation();
     $conversation2 = new Conversation();
     $this->mapper->expects($this->once())->method('getUnreadConversations')->with($user)->will($this->returnValue([$conversation1, $conversation2]));
     $conversations = $this->service->getUnreadConversations($user);
     $this->assertCount(2, $conversations);
     foreach ($conversations as $conversation) {
         $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationInterface', $conversation);
     }
 }