No Description

NullSessionHandlerTest.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\HttpFoundation\Tests\Session\Storage\Handler;
  11. use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
  12. use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
  13. use Symfony\Component\HttpFoundation\Session\Session;
  14. /**
  15. * Test class for NullSessionHandler.
  16. *
  17. * @author Drak <drak@zikula.org>
  18. *
  19. * @runTestsInSeparateProcesses
  20. * @preserveGlobalState disabled
  21. */
  22. class NullSessionHandlerTest extends \PHPUnit_Framework_TestCase
  23. {
  24. public function testSaveHandlers()
  25. {
  26. $storage = $this->getStorage();
  27. $this->assertEquals('user', ini_get('session.save_handler'));
  28. }
  29. public function testSession()
  30. {
  31. session_id('nullsessionstorage');
  32. $storage = $this->getStorage();
  33. $session = new Session($storage);
  34. $this->assertNull($session->get('something'));
  35. $session->set('something', 'unique');
  36. $this->assertEquals('unique', $session->get('something'));
  37. }
  38. public function testNothingIsPersisted()
  39. {
  40. session_id('nullsessionstorage');
  41. $storage = $this->getStorage();
  42. $session = new Session($storage);
  43. $session->start();
  44. $this->assertEquals('nullsessionstorage', $session->getId());
  45. $this->assertNull($session->get('something'));
  46. }
  47. public function getStorage()
  48. {
  49. return new NativeSessionStorage(array(), new NullSessionHandler());
  50. }
  51. }