private function getAuthenticationContext($token = null, $authenticated = false, $authCode = null) { $context = $this->createMock('Scheb\\TwoFactorBundle\\Security\\TwoFactor\\AuthenticationContextInterface'); $context->expects($this->any())->method('getToken')->willReturn($token ? $token : $this->getToken()); $context->expects($this->any())->method('isAuthenticated')->willReturn($authenticated); $request = $this->createMock('Symfony\\Component\\HttpFoundation\\Request'); $request->expects($this->any())->method('get')->with('_auth_code')->willReturn($authCode); $context->expects($this->any())->method('getRequest')->will($this->returnValue($request)); return $context; }