SessionLogoutHandlerTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Http\Tests\Logout;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Security\Http\Logout\SessionLogoutHandler;
  14. class SessionLogoutHandlerTest extends TestCase
  15. {
  16. public function testLogout()
  17. {
  18. $handler = new SessionLogoutHandler();
  19. $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
  20. $response = new Response();
  21. $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
  22. $request
  23. ->expects($this->once())
  24. ->method('getSession')
  25. ->will($this->returnValue($session))
  26. ;
  27. $session
  28. ->expects($this->once())
  29. ->method('invalidate')
  30. ;
  31. $handler->logout($request, $response, $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
  32. }
  33. }