public function testGetUserSetting() { $setting = 'allow_email'; $user = new User(); $settingValue = new SettingValue(); $settingValue->setValue('allow'); $objectRepository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository'); $this->objectManager->expects($this->once())->method('getRepository')->with('Eye4web\\ZfcUser\\Settings\\Entity\\SettingValue')->will($this->returnValue($objectRepository)); $objectRepository->expects($this->once())->method('findOneBy')->with(['user' => $user->getId(), 'setting' => $setting])->will($this->returnValue($settingValue)); $this->assertSame($settingValue, $this->mapper->getUserSetting($setting, $user)); }
public function userIsAlreadyInARoom(User $checkedUser) { $bool = false; foreach ($this->clients as $client) { if ($client->user->getId() == $checkedUser->getId()) { $bool = true; break; } } return $bool; }
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::getUsers */ public function testGetUsers() { $user1 = new User(); $user1->setId(1); $user1->setDisplayName('abdul malik'); $user2 = new User(); $user2->setId(2); $user2->setDisplayName('ikhsan'); $returnValue = [0 => ['id' => 1, 'text' => 'abdul malik'], 1 => ['id' => 2, 'text' => 'ikhsan']]; $this->mapper->expects($this->once())->method('getUsers')->will($this->returnValue([$user1, $user2])); $users = $this->service->getUsers(); $this->assertCount(2, $users); $this->assertEquals(['id' => $user1->getId(), 'text' => $user1->getDisplayName()], $users[0]); $this->assertEquals(['id' => $user2->getId(), 'text' => $user2->getDisplayName()], $users[1]); }
/** * @param User $user * @param Event $event * @return null|object */ public function getRsvpForEventByUser(User $user, Event $event) { $entityRepository = $this->entityManager->getRepository('Application\\Entity\\RSVP'); $rsvp = $entityRepository->findOneBy(['event' => $event->getId(), 'user' => $user->getId()]); return $rsvp; }
/** * @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)); }