* * 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:----nrMzaVuMssHXo1lcsssMcl7EmGNczThvRxA9BZj34ZG408XqHHQDP0JNY9vvAsF3NHfHCsLJgCGU1la0SJytugDhzmBXkwoou0vOgEw0cmf9E/rzANlmo85TfugIQtD1yLzy4CMNVP8FuNFYaMr84bWjGEc7Ak0gd04WKjjq2h3hRmWbgGy1meuObULaycn6RI6XLG5eQFtqKyoNwddZ6b5S/dxSbevy7P/TmVcsMIe+lXeZccE/ChSHoKUdH8XTEK7lP8c83XTilBzr97l1xfbOrFNmVF1TQFzBmO1ZXA5YxdAgap4KT05yC0Skix0t8rwF4gMXPuUtSrqa0+n0JDGIIcDADAcCvdS0iyCPdL3GyvDa7c4R00HdFpqeo7rsd3wMOp7YwREAfEahscnfub8GfNpeF/fS46KSpt81yUPvzELN24D3PHiDzz7sEQLddtWqHdfN65bDlLnyKQfeYFePSIZN2VD3iP1KEf71AhAdlaMfQcFm5fWTWEu0PTZLBtNQ/EPY/211jhG73l6qSOoKH6CrNl6FwkLnhUWwVJVYl0XIgEveujfhP4RgIievPAHhQhmbFLWQcrLhozQJY5vNBANmjAJb5bVfZs+WtSNrWFWERin78O9+4CYlqhcQvQ4FZGKMjedITM924dGnthcFr0notz+tDAaKbTBIPso=----ATTACHMENT:----OTcwMjIzMjc1MjkxMzcwMCA1MTE4MzQ0NzE2OTc5NDQ1IDI5NDc0MDU1NzIzMjczOTE=