/** * @covers Eye4web\ZfcUser\Pm\Entity\ConversationReceiver::__construct * @covers Eye4web\ZfcUser\Pm\Entity\ConversationReceiver::__construct */ public function testConstructSetIdAndDeletedAndUnread() { $conversationReceiver = new Entity(); $this->assertNotNull($conversationReceiver->getId()); $this->assertFalse($conversationReceiver->getDeleted()); $this->assertTrue($conversationReceiver->getUnread()); $this->assertFalse($conversationReceiver->isDeleted()); }
/** * @covers Eye4web\ZfcUser\Pm\Mapper\DoctrineORM\PmMapper::getUnreadConversations */ public function testGetUnreadConversations() { $user = new User(); $user->setId(1); $optionsData = ['to' => $user->getId(), 'unread' => true, 'deleted' => false]; $this->options->expects($this->once())->method('getConversationReceiverEntity')->will($this->returnValue('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationReceiver')); $objectRepository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository'); $this->objectManager->expects($this->once())->method('getRepository')->with('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationReceiver')->will($this->returnValue($objectRepository)); $conversationReceiver1 = new ConversationReceiver(); $conversationReceiver1->setConversation(new Conversation()); $conversationReceiver2 = new ConversationReceiver(); $conversationReceiver2->setConversation(new Conversation()); $objectRepository->expects($this->once())->method('findBy')->with($optionsData)->will($this->returnValue([$conversationReceiver1, $conversationReceiver2])); $unreadConversations = $this->mapper->getUnreadConversations($user); $this->assertCount(2, $unreadConversations); foreach ($unreadConversations as $unreadConversation) { $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationInterface', $unreadConversation); } }