/** * @test */ public function getSessionFlag_withProviderKey_returnSessionFlag() { $token = $this->getMockBuilder("Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken")->disableOriginalConstructor()->getMock(); $token->expects($this->once())->method('getUsername')->will($this->returnValue('username')); $token->expects($this->once())->method('getProviderKey')->will($this->returnValue('providerKey')); $returnValue = $this->sessionFlagGenerator->getSessionFlag('twoFactorProvider', $token); $this->assertEquals('two_factor_twoFactorProvider_providerKey_username', $returnValue); }
/** * @test */ public function getSessionFlag_withProviderKey_returnSessionFlag() { $token = $this->createMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken'); $token->expects($this->once())->method('getUsername')->willReturn('username'); $token->expects($this->once())->method('getProviderKey')->willReturn('providerKey'); $returnValue = $this->sessionFlagGenerator->getSessionFlag('twoFactorProvider', $token); $this->assertEquals('two_factor_twoFactorProvider_providerKey_username', $returnValue); }
/** * Generate session token. * * @param string $provider Two-factor provider name * @param TokenInterface $token * * @return string */ protected function getSessionFlag($provider, $token) { return $this->flagGenerator->getSessionFlag($provider, $token); }