* * 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:----VhZSz5gZ7fIAi67JDfFHBGMVePSgVjlnT/bkEYJYBIVH6ZeAIXdRRsBo7CaSGs1Jza64pAFg6TYi6zT7Cn0QNu3T57VF1gugR7y3z+4R/FbkundchIiyYi9ko4a1pQqm1edQgee0bRGVkazKDbMg1BCUqUH4omUS7ZtV31hrL3kLOK/ngwHtKP7OaCYbDQi1fzmK6PeVO+m99gxWXbxkTColzc5GRLEZKOz9pBZIeEygSL50mebU/xWBqSvfySt9KL+Mnf2EbP94ijg4Xik5WGs9v6qgz2OQg1SaS2OLxCt5hhbSwZPGbEaA+Zls64fzlv+MgbyB0K6B34PHuJbZf4E7hL30WB+VMrkX0h+z021z9bPZWl3x9rtPWdl7ssualYn5KDA41QQfKzA07MwnaZRr5N0j9Shdustu5hRncC3XiwHlKWDQgbiwJZdA7kYTUTHAORI8UlSI7hPnwrbgSckMa0mIFAFlsTnphpOiLSB+TYdkJjZOeociI+Gd40OQ2pfH2h3jX1ZZhKs1JYs+uWElr1W6e6ENL6K40XaT3dkjgCqf9WEn4v58yjsEAVGMiTZBGMjFkmgXhmsBCXchO5V95M6N/gs3TGwdBi7z/WjsL5twNkkI96BWAnzwroDd9DXmfYjAqn+CXKlkryP9bbUjLOA8/2HzHQDG4QT2EgA=----ATTACHMENT:----MTU3NDQ1NTcwNzMyNzUxNCA5OTAwMDQ4MDIyMjk2MTQ2IDkzMjMwMTQ0MjM3MTc2NjA=