4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
16 use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
17 use Symfony\Component\HttpFoundation\Session\Session;
20 * Test class for NullSessionHandler.
22 * @author Drak <drak@zikula.org>
24 * @runTestsInSeparateProcesses
25 * @preserveGlobalState disabled
27 class NullSessionHandlerTest extends TestCase
29 public function testSaveHandlers()
31 $storage = $this->getStorage();
32 $this->assertEquals('user', ini_get('session.save_handler'));
35 public function testSession()
37 session_id('nullsessionstorage');
38 $storage = $this->getStorage();
39 $session = new Session($storage);
40 $this->assertNull($session->get('something'));
41 $session->set('something', 'unique');
42 $this->assertEquals('unique', $session->get('something'));
45 public function testNothingIsPersisted()
47 session_id('nullsessionstorage');
48 $storage = $this->getStorage();
49 $session = new Session($storage);
51 $this->assertEquals('nullsessionstorage', $session->getId());
52 $this->assertNull($session->get('something'));
55 public function getStorage()
57 return new NativeSessionStorage(array(), new NullSessionHandler());