1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
- use PHPUnit\Framework\TestCase;
- use Symfony\Component\HttpFoundation\Session\Session;
- use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
- use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
- class NullSessionHandlerTest extends TestCase
- {
- public function testSaveHandlers()
- {
- $storage = $this->getStorage();
- $this->assertEquals('user', ini_get('session.save_handler'));
- }
- public function testSession()
- {
- session_id('nullsessionstorage');
- $storage = $this->getStorage();
- $session = new Session($storage);
- $this->assertNull($session->get('something'));
- $session->set('something', 'unique');
- $this->assertEquals('unique', $session->get('something'));
- }
- public function testNothingIsPersisted()
- {
- session_id('nullsessionstorage');
- $storage = $this->getStorage();
- $session = new Session($storage);
- $session->start();
- $this->assertEquals('nullsessionstorage', $session->getId());
- $this->assertNull($session->get('something'));
- }
- public function getStorage()
- {
- return new NativeSessionStorage([], new NullSessionHandler());
- }
- }
|