/** * @covers \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::createService */ public function testCreateService() { $adapter = array('adapter1' => $this->getMock('ZfcUser\\Authentication\\Adapter\\AbstractAdapter', array('authenticate', 'logout')), 'adapter2' => $this->getMock('ZfcUser\\Authentication\\Adapter\\AbstractAdapter', array('authenticate', 'logout'))); $adapterNames = array(100 => 'adapter1', 200 => 'adapter2'); $this->serviceLocatorArray = array_merge($this->serviceLocatorArray, $adapter); $this->options->expects($this->once())->method('getAuthAdapters')->will($this->returnValue($adapterNames)); $adapterChain = $this->factory->createService($this->serviceLocator); $this->assertInstanceOf('ZfcUser\\Authentication\\Adapter\\AdapterChain', $adapterChain); $this->assertEquals(array('authenticate', 'logout'), $adapterChain->getEventManager()->getEvents()); }
/** * @covers Eye4web\ZfcUser\Pm\Mapper\DoctrineORM\PmMapper::getUserConversations */ public function testGetUserConversations() { $optionsData = ['to' => 1, 'deleted' => false]; $this->options->expects($this->any())->method('getConversationReceiverEntity')->will($this->returnValue('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationReceiver')); $objectRepository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository'); $this->objectManager->expects($this->any())->method('getRepository')->with('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationReceiver')->will($this->returnValue($objectRepository)); $conversationReceivers[0] = new ConversationReceiver(); $conversationReceivers[0]->setConversation(new Conversation()); $conversationReceivers[1] = new ConversationReceiver(); $conversationReceivers[1]->setConversation(new Conversation()); $objectRepository->expects($this->any())->method('findBy')->with($optionsData)->will($this->returnValue([$conversationReceivers[0], $conversationReceivers[1]])); $this->zfcuserOptions->expects($this->any())->method('getUserEntityClass')->will($this->returnValue('ZfcUser\\Entity\\User')); $participants = []; $user[0] = new User(); $user[0]->setId(1); $user[1] = new User(); $user[1]->setId(2); $conversations = []; foreach ($conversationReceivers as $key => $conversationReceiver) { $conversations[] = $conversationReceiver->getConversation(); } $conversations = $this->mapper->getUserConversations(1); $this->assertCount(2, $conversations); foreach ($conversations as $conversation) { $this->assertInstanceOf('Eye4web\\ZfcUser\\Pm\\Entity\\ConversationInterface', $conversation); } }
public function testGetRedirectWithOptionOnRedirectDoesntExists() { $route = 'zfcuser/login'; $redirect = 'doesntExists'; $expectedResult = '/user/login'; $this->moduleOptions->expects($this->once())->method('getUseRedirectParameterIfPresent')->will($this->returnValue(true)); $this->router->expects($this->at(0))->method('assemble')->with(array(), array('name' => $redirect))->will($this->throwException(new \Zend\Mvc\Router\Exception\RuntimeException())); $this->router->expects($this->at(1))->method('assemble')->with(array(), array('name' => $route))->will($this->returnValue($expectedResult)); $this->moduleOptions->expects($this->once())->method('getLoginRedirectRoute')->will($this->returnValue($route)); $method = new \ReflectionMethod('ZfcUser\\Controller\\RedirectCallback', 'getRedirect'); $method->setAccessible(true); $result = $method->invoke($this->redirectCallback, $route, $redirect); $this->assertSame($expectedResult, $result); }