コード例 #1
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $formElementManager = $serviceLocator->getServiceLocator()->get('FormElementManager');
     $loginForm = $formElementManager->get('UghAuthentication\\Form\\Login');
     $moduleOptions = $serviceLocator->getServiceLocator()->get('UghAuthentication\\Options\\ModuleOptions');
     $controller = new LoginController($loginForm);
     $controller->setLoginRedirectRoute($moduleOptions->getLoginRedirectRoute());
     return $controller;
 }
コード例 #2
0
 public function testPostValidLogin()
 {
     $loginFormMock = $this->getMock('Zend\\Form\\FormInterface');
     $loginFormMock->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $controller = new LoginController($loginFormMock);
     $controller->setLoginRedirectRoute('my-crazy-login-redirect-route');
     $pluginManagerMock = $this->getMock('Zend\\Mvc\\Controller\\PluginManager', array('get'));
     $pluginManagerMock->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'getPluginMockCallback')));
     $controller->setPluginManager($pluginManagerMock);
     $requestMock = $this->getMock('Zend\\Http\\Request');
     $requestMock->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $this->setReflectionObjectProperty($controller, 'request', $requestMock);
     $result = $controller->indexAction();
     $this->assertInstanceOf('Zend\\Http\\Response', $result);
 }