/**
  * @dataProvider providerTrueOrFalse
  * @depend testActionControllHasIdentity
  */
 public function testLoginActionIsNotPost($redirect)
 {
     $plugin = $this->setUpZfcUserAuthenticationPlugin(array('hasIdentity' => false));
     $flashMessenger = $this->getMock('Zend\\Mvc\\Controller\\Plugin\\FlashMessenger');
     $flashMessenger->expects($this->once())->method('setNamespace')->with('zfcuser-login-form')->will($this->returnSelf());
     $this->pluginManagerPlugins['flashMessenger'] = $flashMessenger;
     $request = $this->getMock('Zend\\Http\\Request');
     $request->expects($this->once())->method('isPost')->will($this->returnValue(false));
     $form = $this->getMockBuilder('ZfcUser\\Form\\Login')->disableOriginalConstructor()->getMock();
     $form->expects($this->never())->method('isValid');
     $this->options->expects($this->any())->method('getUseRedirectParameterIfPresent')->will($this->returnValue((bool) $redirect));
     if ($redirect) {
         $params = new Parameters();
         $params->set('redirect', 'http://localhost/');
         $request->expects($this->any())->method('getQuery')->will($this->returnValue($params));
     }
     $this->helperMakePropertyAccessable($this->controller, 'request', $request);
     $this->controller->setLoginForm($form);
     $result = $this->controller->loginAction();
     $this->assertArrayHasKey('loginForm', $result);
     $this->assertArrayHasKey('redirect', $result);
     $this->assertArrayHasKey('enableRegistration', $result);
     $this->assertInstanceOf('\\ZfcUser\\Form\\Login', $result['loginForm']);
     $this->assertSame($form, $result['loginForm']);
     if ($redirect) {
         $this->assertEquals('http://localhost/', $result['redirect']);
     } else {
         $this->assertFalse($result['redirect']);
     }
     $this->assertEquals($this->options->getEnableRegistration(), $result['enableRegistration']);
 }
 public function createService(ServiceLocatorInterface $sm)
 {
     $userService = $sm->get('zfcuser_user_service');
     $loginEvents = $sm->get('EventManager');
     $loginForm = $sm->get('ZfcUser\\Form\\Login');
     $loginForm->setEventManager($loginEvents);
     $registerForm = $sm->get('ZfcUser\\Form\\Register');
     $controller = new UserController();
     $controller->setUserService($userService);
     $controller->setLoginForm($loginForm);
     $controller->setRegisterForm($registerForm);
     $controller->setServiceLocator($sm);
     return $controller;
 }