Skip to content

Commit

Permalink
Refactor SessionStorage to NativeSessionStorage.
Browse files Browse the repository at this point in the history
Native here refers to the fact the session storage interacts with real PHP sessions.
  • Loading branch information
Drak committed Mar 14, 2012
1 parent b12ece0 commit 7f33b33
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
$this->addClassesToCompile(array(
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorage',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\NativeSessionHandler',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\AbstractProxy',
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\SessionHandlerProxy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parameter key="session.class">Symfony\Component\HttpFoundation\Session\Session</parameter>
<parameter key="session.flashbag.class">Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag</parameter>
<parameter key="session.attribute_bag.class">Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag</parameter>
<parameter key="session.storage.native.class">Symfony\Component\HttpFoundation\Session\Storage\SessionStorage</parameter>
<parameter key="session.storage.native.class">Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage</parameter>
<parameter key="session.storage.mock_file.class">Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage</parameter>
<parameter key="session.handler.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler</parameter>
<parameter key="session_listener.class">Symfony\Bundle\FrameworkBundle\EventListener\SessionListener</parameter>
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpFoundation/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;

/**
* Session.
Expand Down Expand Up @@ -45,7 +45,7 @@ class Session implements SessionInterface
*/
public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
{
$this->storage = $storage ?: new SessionStorage();
$this->storage = $storage ?: new NativeSessionStorage();
$this->registerBag($attributes ?: new AttributeBag());
$this->registerBag($flashes ?: new FlashBag());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Drak <drak@zikula.org>
*/
class SessionStorage implements SessionStorageInterface
class NativeSessionStorage implements SessionStorageInterface
{
/**
* Array of SessionBagInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;

use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;

/**
* Test class for NativeFileSessionHandler.
Expand All @@ -16,7 +16,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$storage = new SessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));

if (version_compare(phpversion(), '5.4.0', '<')) {
$this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName());
Expand All @@ -33,7 +33,7 @@ public function testConstruct()
public function testConstructDefault()
{
$path = ini_get('session.save_path');
$storage = new SessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler());
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler());

$this->assertEquals($path, ini_get('session.save_path'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;

use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcacheSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;

/**
* Test class for NativeMemcacheSessionHandler.
Expand All @@ -20,7 +20,7 @@ public function testSaveHandlers()
$this->markTestSkipped('Skipped tests SQLite extension is not present');
}

$storage = new SessionStorage(array('name' => 'TESTING'), new NativeMemcacheSessionHandler('tcp://127.0.0.1:11211?persistent=0'));
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcacheSessionHandler('tcp://127.0.0.1:11211?persistent=0'));

if (version_compare(phpversion(), '5.4.0', '<')) {
$this->assertEquals('memcache', $storage->getSaveHandler()->getSaveHandlerName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;

use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcachedSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;

/**
* Test class for NativeMemcachedSessionHandler.
Expand All @@ -23,7 +23,7 @@ public function testSaveHandlers()
// test takes too long if memcached server is not running
ini_set('memcached.sess_locking', '0');

$storage = new SessionStorage(array('name' => 'TESTING'), new NativeMemcachedSessionHandler('127.0.0.1:11211'));
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcachedSessionHandler('127.0.0.1:11211'));

if (version_compare(phpversion(), '5.4.0', '<')) {
$this->assertEquals('memcached', $storage->getSaveHandler()->getSaveHandlerName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;

use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSqliteSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;

/**
* Test class for NativeSqliteSessionStorage.
Expand All @@ -20,7 +20,7 @@ public function testSaveHandlers()
$this->markTestSkipped('Skipped tests SQLite extension is not present');
}

$storage = new SessionStorage(array('name' => 'TESTING'), new NativeSqliteSessionHandler(sys_get_temp_dir().'/sqlite.db'));
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeSqliteSessionHandler(sys_get_temp_dir().'/sqlite.db'));

if (version_compare(phpversion(), '5.4.0', '<')) {
$this->assertEquals('sqlite', $storage->getSaveHandler()->getSaveHandlerName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Symfony\Component\HttpFoundation\Session\Session;

/**
Expand Down Expand Up @@ -42,7 +42,7 @@ public function testNothingIsPersisted()

public function getStorage()
{
return new SessionStorage(array(), new NullSessionHandler());
return new NativeSessionStorage(array(), new NullSessionHandler());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;

use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
Expand All @@ -17,14 +17,14 @@
*
* @runTestsInSeparateProcesses
*/
class SessionStorageTest extends \PHPUnit_Framework_TestCase
class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
{
/**
* @return AbstractSessionStorage
* @return NativeSessionStorage
*/
protected function getStorage(array $options = array())
{
$storage = new SessionStorage($options);
$storage = new NativeSessionStorage($options);
$storage->registerBag(new AttributeBag);

return $storage;
Expand Down Expand Up @@ -82,15 +82,15 @@ public function testDefaultSessionCacheLimiter()
{
ini_set('session.cache_limiter', 'nocache');

$storage = new SessionStorage();
$storage = new NativeSessionStorage();
$this->assertEquals('', ini_get('session.cache_limiter'));
}

public function testExplicitSessionCacheLimiter()
{
ini_set('session.cache_limiter', 'nocache');

$storage = new SessionStorage(array('cache_limiter' => 'public'));
$storage = new NativeSessionStorage(array('cache_limiter' => 'public'));
$this->assertEquals('public', ini_get('session.cache_limiter'));
}

Expand Down

0 comments on commit 7f33b33

Please sign in to comment.