public function testGetUserImage()
 {
     $options = new ModuleOptions(['upload_directory' => 'upload_directory']);
     $storageModel = new StorageModel($options);
     $user = new User();
     $user->setId(4);
     $this->assertEquals('upload_directory/4.png', $storageModel->getUserImage($user));
 }
 public function testExtract()
 {
     $user = new User();
     $user->setId(13);
     $entity = new UserRegistration($user);
     $entity->setToken('fund');
     $requestTime = new \DateTime('2013-09-13 08:08:08');
     $entity->setRequestTime($requestTime);
     $entity->setResponded(true);
     $data = (new UserRegistrationHydrator())->extract($entity);
     $this->assertEquals(13, $data['user_id']);
     $this->assertEquals(true, $data['responded']);
     $this->assertEquals('fund', $data['token']);
     $this->assertEquals($requestTime->getTimestamp(), (new \DateTime($data['request_time']))->getTimestamp());
 }
Exemplo n.º 3
0
 public function providerTestFindBy()
 {
     $user = new Entity();
     $user->setEmail('*****@*****.**');
     $user->setUsername('zfc-user');
     $user->setDisplayName('Zfc-User');
     $user->setId('1');
     $user->setState(1);
     $user->setPassword('zfc-user');
     return array(array('findByEmail', array($user->getEmail()), array('whereArgs' => array(array('email' => $user->getEmail()), 'AND')), array(), $user), array('findByUsername', array($user->getUsername()), array('whereArgs' => array(array('username' => $user->getUsername()), 'AND')), array(), $user), array('findById', array($user->getId()), array('whereArgs' => array(array('user_id' => $user->getId()), 'AND')), array(), $user));
 }
 /**
  * @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);
     }
 }
Exemplo n.º 5
0
 /**
  * @covers Eye4web\ZfcUser\Pm\Mapper\DoctrineORM\PmMapper::isUnread
  */
 public function testIsUnread()
 {
     $conversation = new Conversation();
     $conversation->setId(1);
     $user = new User();
     $user->setId(1);
     $optionsData = ['conversation' => $conversation->getId(), 'to' => $user->getId()];
     $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));
     $conversationReceive = $this->getMock('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationReceiver');
     $objectRepository->expects($this->once())->method('findOneBy')->with($optionsData)->will($this->returnValue($conversationReceive));
     $conversationReceive->expects($this->once())->method('getUnread')->will($this->returnValue(true));
     $this->assertTrue($this->mapper->isUnread($conversation, $user));
 }