/**
  * @dataProvider getUsernameForLength
  */
 public function testHandleWhenUsernameLength($username, $ok)
 {
     $request = Request::create('/login_check', 'POST', array('_username' => $username));
     $request->setSession($this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface')->getMock());
     $httpUtils = $this->getMockBuilder('Symfony\\Component\\Security\\Http\\HttpUtils')->getMock();
     $httpUtils->expects($this->any())->method('checkRequestPath')->will($this->returnValue(true));
     $failureHandler = $this->getMockBuilder('Symfony\\Component\\Security\\Http\\Authentication\\AuthenticationFailureHandlerInterface')->getMock();
     $failureHandler->expects($ok ? $this->never() : $this->once())->method('onAuthenticationFailure')->will($this->returnValue(new Response()));
     $authenticationManager = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationProviderManager')->disableOriginalConstructor()->getMock();
     $authenticationManager->expects($ok ? $this->once() : $this->never())->method('authenticate')->will($this->returnValue(new Response()));
     $listener = new UsernamePasswordFormAuthenticationListener($this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface')->getMock(), $authenticationManager, $this->getMockBuilder('Symfony\\Component\\Security\\Http\\Session\\SessionAuthenticationStrategyInterface')->getMock(), $httpUtils, 'TheProviderKey', $this->getMockBuilder('Symfony\\Component\\Security\\Http\\Authentication\\AuthenticationSuccessHandlerInterface')->getMock(), $failureHandler, array('require_previous_session' => false));
     $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
     $listener->handle($event);
 }