* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Tests\Session; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy; class SessionAuthenticationStrategyTest extends TestCase { public function testSessionIsNotChanged() { $request = $this->getRequest(); $request->expects($this->never())->method('getSession'); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE); $strategy->onAuthentication($request, $this->getToken()); } /** * @expectedException \RuntimeException * @expectedExceptionMessage Invalid session authentication strategy "foo" */ public function testUnsupportedStrategy() { $request = $this->getRequest(); $request->expects($this->never())->method('getSession'); $strategy = new SessionAuthenticationStrategy('foo'); $strategy->onAuthentication($request, $this->getToken()); } public function testSessionIsMigrated() { $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once())->method('migrate')->with($this->equalTo(true)); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); $strategy->onAuthentication($this->getRequest($session), $this->getToken()); } public function testSessionIsInvalidated() { $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once())->method('invalidate'); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::INVALIDATE); $strategy->onAuthentication($this->getRequest($session), $this->getToken()); } private function getRequest($session = null) { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); if (null !== $session) { $request->expects($this->any())->method('getSession')->will($this->returnValue($session)); } return $request; } private function getToken() { return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } } __halt_compiler();----SIGNATURE:----DXacKL4izjmgAlNOYyzqoVVqKNtJW4Jg+saPE4o7Caq7lwbTmLqDU5eFbzEzRuVuz6p+CvRhDuRNSJ5W7Auy0eY6T63HGxn4+1bO8XhlcK95J8DL+QjM7ptui6QaU4VVbRNz9p8YKJKiObz53C1qxHlrNBTyg/rahP1g/QZYFD4bP+b7rtXp+CcmqT3BsvlmMi0/31ZoaRY0dbr4KpgZ5g/y6zp6cB4u+Rd6pIQplRQR9+8oy98K+I1wSDKIbwBpNL75T9H25FL/aqKLfugxI3JFBt86pod9XDa6BscM1uUsaXgNpSo4Zm81b2rTz5FImkxO8juLRMsqlqmcvPYZu5jPbl5V+YIQ0t2+ShGBvqE1ktHGN/lo+zAMghCvr4O6utP0Qlwv6F51xtTw5jwizYSLJR9oztgEuZVI7eCwVGwA9pTaM5iSyecTq34UgDm3mWtZ/qzpPe4GQW0aTYNTQQmmOKE7/D/xH2mTiOjaUFoLdrAQpzVqshHNySjs/XULT2rEl5Ch5IoqvOhXGzCzZEWLt3Jlycpz6t/Q/sALJVDpEt7YfSeTSrMn1zP29gZEtdYwQD+QRgB32GW3XcIsvbWJw0T9E28dL/+2yEiovOO5KUuXZrvrpGFIZ/WiDsPQXeR3389Xvp6Y6ORtedf8NN0MRuWw13nESjywPDAHMWE=----ATTACHMENT:----ODAzODU1NTM4OTUzNzY2MSA4MTgzMjIxNzQ2NTU0MTAwIDQ4MDg3NDQ3Nzk0NTgyOTA=