authenticate() public method

public authenticate ( Request $request )
$request Symfony\Component\HttpFoundation\Request
 public function testAuthenticatePreviousTokenNotUsernamePassword()
 {
     $username = '******';
     $password = '******';
     $existingToken = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $existingToken->expects($this->once())->method('getUsername')->will($this->returnValue(__METHOD__));
     $request = new Request();
     $request->attributes->set('username', $username);
     $request->attributes->set('password', $password);
     $usernamePasswordToken = new UsernamePasswordToken($username, $password, self::PROVIDER_KEY);
     $authenticatedToken = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->disableOriginalConstructor()->getMock();
     $this->authenticationManager->expects($this->once())->method('authenticate')->with($this->equalTo($usernamePasswordToken))->will($this->returnValue($authenticatedToken));
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(SecurityEvents::INTERACTIVE_LOGIN, $this->equalTo(new InteractiveLoginEvent($request, $authenticatedToken)));
     $this->tokenStorage->expects($this->at(0))->method('getToken')->will($this->returnValue($existingToken));
     $this->tokenStorage->expects($this->at(1))->method('setToken')->with($authenticatedToken);
     $this->tokenStorage->expects($this->at(2))->method('getToken')->will($this->returnValue($authenticatedToken));
     $authenticatedUser = $this->createUser(456);
     $authenticatedToken->expects($this->once())->method('getUser')->will($this->returnValue($authenticatedUser));
     $this->assertSame($authenticatedToken, $this->authenticator->authenticate($request));
 }