[HttpFoundation] Simplify session storage class names now we have a separate namespace for sessions.
This commit is contained in:
parent
27530cbb1e
commit
5b7ef11650
@ -230,7 +230,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
|||||||
* added ResponseHeaderBag::makeDisposition() (implements RFC 6266)
|
* added ResponseHeaderBag::makeDisposition() (implements RFC 6266)
|
||||||
* made mimetype to extension conversion configurable
|
* made mimetype to extension conversion configurable
|
||||||
* [BC BREAK] Moved all session related classes and interfaces into own namespace, as
|
* [BC BREAK] Moved all session related classes and interfaces into own namespace, as
|
||||||
`Symfony\Component\HttpFoudation\Session`.
|
`Symfony\Component\HttpFoudation\Session` and renamed classes accordingly.
|
||||||
* Flashes are now stored as a bucket of messages per `$type` so there can be multiple messages per type.
|
* Flashes are now stored as a bucket of messages per `$type` so there can be multiple messages per type.
|
||||||
There are four interface constants for type, `FlashBagInterface::INFO`, `FlashBagInterface::NOTICE`,
|
There are four interface constants for type, `FlashBagInterface::INFO`, `FlashBagInterface::NOTICE`,
|
||||||
`FlashBagInterface::WARNING` and `FlashBagInterface::ERROR`.
|
`FlashBagInterface::WARNING` and `FlashBagInterface::ERROR`.
|
||||||
@ -242,19 +242,23 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
|||||||
`getFlash()`, `hasFlash()`, andd `removeFlash()`. `getFlashes() returns a `FlashBagInterface`.
|
`getFlash()`, `hasFlash()`, andd `removeFlash()`. `getFlashes() returns a `FlashBagInterface`.
|
||||||
* `Session->clear()` now only clears session attributes as before it cleared flash messages and
|
* `Session->clear()` now only clears session attributes as before it cleared flash messages and
|
||||||
attributes. `Session->getFlashes()->popAll()` clears flashes now.
|
attributes. `Session->getFlashes()->popAll()` clears flashes now.
|
||||||
* Added `AbstractSessionStorage` base class for session storage drivers.
|
* Added `Symfony\Component\HttpFoundation\Session\Storage\AbstractStorage` base class for
|
||||||
* Added `SessionSaveHandler` interface which storage drivers should implement after inheriting from
|
session storage drivers.
|
||||||
`AbstractSessionStorage` when writing custom session save handlers.
|
* Added `Symfony\Component\HttpFoundation\Session\Storage\SaveHandlerInterface` interface
|
||||||
* [BC BREAK] `SessionStorageInterface` methods removed: `write()`, `read()` and `remove()`. Added
|
which storage drivers should implement after inheriting from
|
||||||
`getAttributes()`, `getFlashes()`.
|
`Symfony\Component\HttpFoundation\Session\Storage\AbstractStorage` when writing custom session save handlers.
|
||||||
* Moved attribute storage to `AttributeBagInterface`.
|
* [BC BREAK] `StorageInterface` methods removed: `write()`, `read()` and `remove()`. Added
|
||||||
* Added `AttributeBag` to replicate attributes storage behaviour from 2.0.x (default).
|
`getBag()`, `registerBag()`.
|
||||||
* Added `NamespacedAttributeBag` for namespace session attributes.
|
* Moved attribute storage to `Symfony\Component\HttpFoundation\Attribute\AttributeBagInterface`.
|
||||||
* Session now implements `SessionInterface` making implementation customizable and portable.
|
* Added `Symfony\Component\HttpFoundation\Attribute\AttributeBag` to replicate attributes storage
|
||||||
* [BC BREAK] Removed `NativeSessionStorage` and replaced with `NativeFileSessionStorage`.
|
behaviour from 2.0.x (default).
|
||||||
|
* Added `Symfony\Component\HttpFoundation\Attribute\NamespacedAttributeBag` for namespace session attributes.
|
||||||
|
* Session now implements `Symfony\Component\HttpFoundation\Session\SessionInterface` making
|
||||||
|
implementation customizable and portable.
|
||||||
|
* [BC BREAK] Removed `NativeStorage` and replaced with `NativeFileStorage`.
|
||||||
* Added session storage drivers for PHP native Memcache, Memcached and SQLite session save handlers.
|
* Added session storage drivers for PHP native Memcache, Memcached and SQLite session save handlers.
|
||||||
* Added session storage drivers for custom Memcache, Memcached and Null session save handlers.
|
* Added session storage drivers for custom Memcache, Memcached and Null session save handlers.
|
||||||
* Removed `FilesystemSessionStorage`, use `MockFileSessionStorage` for functional testing instead.
|
* Removed `FilesystemStorage`, use `MockFileStorage` for functional testing instead.
|
||||||
|
|
||||||
### HttpKernel
|
### HttpKernel
|
||||||
|
|
||||||
|
@ -313,9 +313,9 @@ UPGRADE FROM 2.0 to 2.1
|
|||||||
* Session storage drivers
|
* Session storage drivers
|
||||||
|
|
||||||
Session storage drivers should inherit from
|
Session storage drivers should inherit from
|
||||||
`Symfony\Component\HttpFoundation\Session\Storage\AbstractSessionStorage`
|
`Symfony\Component\HttpFoundation\Session\Storage\AbstractStorage`
|
||||||
and no longer should implement `read()`, `write()`, `remove()` which were removed from the
|
and no longer should implement `read()`, `write()`, `remove()` which were removed from the
|
||||||
`SessionStorageInterface`.
|
`StorageInterface`.
|
||||||
|
|
||||||
Any session storage driver that wants to use custom save handlers should
|
Any session storage driver that wants to use custom save handlers should
|
||||||
implement `Symfony\Component\HttpFoundation\Session\Storage\SessionSaveHandlerInterface`
|
implement `Symfony\Component\HttpFoundation\Session\Storage\SessionSaveHandlerInterface`
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Symfony\Bridge\Doctrine\HttpFoundation;
|
namespace Symfony\Bridge\Doctrine\HttpFoundation;
|
||||||
|
|
||||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\AbstractSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\AbstractStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\SessionSaveHandlerInterface;
|
use Symfony\Component\HttpFoundation\Session\Storage\SessionSaveHandlerInterface;
|
||||||
use Doctrine\DBAL\Driver\Connection;
|
use Doctrine\DBAL\Driver\Connection;
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ use Doctrine\DBAL\Driver\Connection;
|
|||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||||
*/
|
*/
|
||||||
class DbalSessionStorage extends AbstractSessionStorage implements SessionSaveHandlerInterface
|
class DbalStorage extends AbstractStorage implements SessionSaveHandlerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Connection
|
* @var Connection
|
||||||
|
@ -9,7 +9,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||||||
*
|
*
|
||||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||||
*/
|
*/
|
||||||
final class DbalSessionStorageSchema extends Schema
|
final class DbalStorageSchema extends Schema
|
||||||
{
|
{
|
||||||
private $tableName;
|
private $tableName;
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
$this->addClassesToCompile(array(
|
$this->addClassesToCompile(array(
|
||||||
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
|
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
|
||||||
'Symfony\\Component\\HttpFoundation\\Session\Storage\\SessionStorageInterface',
|
'Symfony\\Component\\HttpFoundation\\Session\Storage\\StorageInterface',
|
||||||
$container->getDefinition('session')->getClass(),
|
$container->getDefinition('session')->getClass(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
<parameter key="session.class">Symfony\Component\HttpFoundation\Session\Session</parameter>
|
<parameter key="session.class">Symfony\Component\HttpFoundation\Session\Session</parameter>
|
||||||
<parameter key="session.flashbag.class">Symfony\Component\HttpFoundation\Session\Flash\FlashBag</parameter>
|
<parameter key="session.flashbag.class">Symfony\Component\HttpFoundation\Session\Flash\FlashBag</parameter>
|
||||||
<parameter key="session.attribute_bag.class">Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag</parameter>
|
<parameter key="session.attribute_bag.class">Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag</parameter>
|
||||||
<parameter key="session.storage.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\NativeFileSessionStorage</parameter>
|
<parameter key="session.storage.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\NativeFileStorage</parameter>
|
||||||
<parameter key="session.storage.null.class">Symfony\Component\HttpFoundation\Session\Storage\NullSessionStorage</parameter>
|
<parameter key="session.storage.null.class">Symfony\Component\HttpFoundation\Session\Storage\NullStorage</parameter>
|
||||||
<parameter key="session.storage.native_memcache.class">Symfony\Component\HttpFoundation\Session\Storage\NativeMemcacheSessionStorage</parameter>
|
<parameter key="session.storage.native_memcache.class">Symfony\Component\HttpFoundation\Session\Storage\NativeMemcacheStorage</parameter>
|
||||||
<parameter key="session.storage.native_memcached.class">Symfony\Component\HttpFoundation\Session\Storage\NativeMemcachedSessionStorage</parameter>
|
<parameter key="session.storage.native_memcached.class">Symfony\Component\HttpFoundation\Session\Storage\NativeMemcachedStorage</parameter>
|
||||||
<parameter key="session.storage.native_sqlite.class">Symfony\Component\HttpFoundation\Session\Storage\NativeSqliteSessionStorage</parameter>
|
<parameter key="session.storage.native_sqlite.class">Symfony\Component\HttpFoundation\Session\Storage\NativeSqliteStorage</parameter>
|
||||||
<parameter key="session.storage.memcache.class">Symfony\Component\HttpFoundation\Session\Storage\MemcacheSessionStorage</parameter>
|
<parameter key="session.storage.memcache.class">Symfony\Component\HttpFoundation\Session\Storage\MemcacheStorage</parameter>
|
||||||
<parameter key="session.storage.memcached.class">Symfony\Component\HttpFoundation\Session\Storage\MemcachedSessionStorage</parameter>
|
<parameter key="session.storage.memcached.class">Symfony\Component\HttpFoundation\Session\Storage\MemcachedStorage</parameter>
|
||||||
<parameter key="session.storage.mock_file.class">Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage</parameter>
|
<parameter key="session.storage.mock_file.class">Symfony\Component\HttpFoundation\Session\Storage\MockFileStorage</parameter>
|
||||||
<parameter key="session.memcache.class">Memcache</parameter>
|
<parameter key="session.memcache.class">Memcache</parameter>
|
||||||
<parameter key="session.memcached.class">Memcached</parameter>
|
<parameter key="session.memcached.class">Memcached</parameter>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArrayStorage;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
|
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
@ -26,7 +26,7 @@ class SessionHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->request = new Request();
|
$this->request = new Request();
|
||||||
|
|
||||||
$session = new Session(new MockArraySessionStorage());
|
$session = new Session(new MockArrayStorage());
|
||||||
$session->set('foobar', 'bar');
|
$session->set('foobar', 'bar');
|
||||||
$session->getFlashes()->set(FlashBag::NOTICE, 'bar');
|
$session->getFlashes()->set(FlashBag::NOTICE, 'bar');
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Templating\PhpEngine;
|
|||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArrayStorage;
|
||||||
use Symfony\Component\Templating\TemplateNameParser;
|
use Symfony\Component\Templating\TemplateNameParser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
@ -64,7 +64,7 @@ class PhpEngineTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$session = new Session(new MockArraySessionStorage());
|
$session = new Session(new MockArrayStorage());
|
||||||
|
|
||||||
$request->setSession($session);
|
$request->setSession($session);
|
||||||
$container->set('request', $request);
|
$container->set('request', $request);
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Bundle\TwigBundle\TwigEngine;
|
|||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArrayStorage;
|
||||||
use Symfony\Component\Templating\TemplateNameParser;
|
use Symfony\Component\Templating\TemplateNameParser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class TwigEngineTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new Container();
|
$container = new Container();
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$session = new Session(new MockArraySessionStorage());
|
$session = new Session(new MockArrayStorage());
|
||||||
|
|
||||||
$request->setSession($session);
|
$request->setSession($session);
|
||||||
$container->set('request', $request);
|
$container->set('request', $request);
|
||||||
|
@ -43,8 +43,8 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
|||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>request -> getRequestService()</li>
|
* <li>request -> getRequestService()</li>
|
||||||
* <li>mysql_session_storage -> getMysqlSessionStorageService()</li>
|
* <li>mysql_session_storage -> getMysqlStorageService()</li>
|
||||||
* <li>symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()</li>
|
* <li>symfony.mysql_session_storage -> getSymfony_MysqlStorageService()</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* The container can have three possible behaviors when a service does not exist:
|
* The container can have three possible behaviors when a service does not exist:
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpFoundation\Session;
|
namespace Symfony\Component\HttpFoundation\Session;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
|
use Symfony\Component\HttpFoundation\Session\Storage\StorageInterface;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
@ -31,18 +31,18 @@ class Session implements SessionInterface
|
|||||||
/**
|
/**
|
||||||
* Storage driver.
|
* Storage driver.
|
||||||
*
|
*
|
||||||
* @var SessionStorageInterface
|
* @var StorageInterface
|
||||||
*/
|
*/
|
||||||
protected $storage;
|
protected $storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param SessionStorageInterface $storage A SessionStorageInterface instance.
|
* @param StorageInterface $storage A StorageInterface instance.
|
||||||
* @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag)
|
* @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag)
|
||||||
* @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag)
|
* @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag)
|
||||||
*/
|
*/
|
||||||
public function __construct(SessionStorageInterface $storage, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
|
public function __construct(StorageInterface $storage, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
|
||||||
{
|
{
|
||||||
$this->storage = $storage;
|
$this->storage = $storage;
|
||||||
$this->registerBag($attributes ?: new AttributeBag());
|
$this->registerBag($attributes ?: new AttributeBag());
|
||||||
@ -204,7 +204,7 @@ class Session implements SessionInterface
|
|||||||
/**
|
/**
|
||||||
* Implements the \Serialize interface.
|
* Implements the \Serialize interface.
|
||||||
*
|
*
|
||||||
* @return SessionStorageInterface
|
* @return StorageInterface
|
||||||
*/
|
*/
|
||||||
public function serialize()
|
public function serialize()
|
||||||
{
|
{
|
||||||
@ -214,13 +214,13 @@ class Session implements SessionInterface
|
|||||||
/**
|
/**
|
||||||
* Implements the \Serialize interface.
|
* Implements the \Serialize interface.
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the passed string does not unserialize to an instance of SessionStorageInterface
|
* @throws \InvalidArgumentException If the passed string does not unserialize to an instance of StorageInterface
|
||||||
*/
|
*/
|
||||||
public function unserialize($serialized)
|
public function unserialize($serialized)
|
||||||
{
|
{
|
||||||
$storage = unserialize($serialized);
|
$storage = unserialize($serialized);
|
||||||
if (!$storage instanceof SessionStorageInterface) {
|
if (!$storage instanceof StorageInterface) {
|
||||||
throw new \InvalidArgumentException('Serialized data did not return a valid instance of SessionStorageInterface');
|
throw new \InvalidArgumentException('Serialized data did not return a valid instance of StorageInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->storage = $storage;
|
$this->storage = $storage;
|
||||||
|
@ -22,7 +22,7 @@ use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
|||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
abstract class AbstractSessionStorage implements SessionStorageInterface
|
abstract class AbstractStorage implements StorageInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Array of SessionBagInterface
|
* Array of SessionBagInterface
|
||||||
@ -297,7 +297,7 @@ abstract class AbstractSessionStorage implements SessionStorageInterface
|
|||||||
{
|
{
|
||||||
// note this can be reset to PHP's control using ini_set('session.save_handler', 'files');
|
// note this can be reset to PHP's control using ini_set('session.save_handler', 'files');
|
||||||
// so long as ini_set() is called before the session is started.
|
// so long as ini_set() is called before the session is started.
|
||||||
if ($this instanceof SessionSaveHandlerInterface) {
|
if ($this instanceof SaveHandlerInterface) {
|
||||||
session_set_save_handler(
|
session_set_save_handler(
|
||||||
array($this, 'openSession'),
|
array($this, 'openSession'),
|
||||||
array($this, 'closeSession'),
|
array($this, 'closeSession'),
|
@ -12,11 +12,11 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MemcacheSessionStorage.
|
* MemcacheStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class MemcacheSessionStorage extends AbstractSessionStorage implements SessionSaveHandlerInterface
|
class MemcacheStorage extends AbstractStorage implements SaveHandlerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Memcache driver.
|
* Memcache driver.
|
||||||
@ -46,7 +46,7 @@ class MemcacheSessionStorage extends AbstractSessionStorage implements SessionSa
|
|||||||
* @param array $memcacheOptions An associative array of Memcachge options
|
* @param array $memcacheOptions An associative array of Memcachge options
|
||||||
* @param array $options Session configuration options.
|
* @param array $options Session configuration options.
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct(\Memcache $memcache, array $memcacheOptions = array(), array $options = array())
|
public function __construct(\Memcache $memcache, array $memcacheOptions = array(), array $options = array())
|
||||||
{
|
{
|
@ -12,11 +12,11 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MemcachedSessionStorage.
|
* MemcachedStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class MemcachedSessionStorage extends AbstractSessionStorage implements SessionSaveHandlerInterface
|
class MemcachedStorage extends AbstractStorage implements SaveHandlerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Memcached driver.
|
* Memcached driver.
|
||||||
@ -39,7 +39,7 @@ class MemcachedSessionStorage extends AbstractSessionStorage implements SessionS
|
|||||||
* @param array $memcachedOptions An associative array of Memcached options
|
* @param array $memcachedOptions An associative array of Memcached options
|
||||||
* @param array $options Session configuration options.
|
* @param array $options Session configuration options.
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct(\Memcached $memcache, array $memcachedOptions = array(), array $options = array())
|
public function __construct(\Memcached $memcache, array $memcachedOptions = array(), array $options = array())
|
||||||
{
|
{
|
@ -12,18 +12,18 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MockArraySessionStorage mocks the session for unit tests.
|
* MockArrayStorage mocks the session for unit tests.
|
||||||
*
|
*
|
||||||
* No PHP session is actually started since a session can be initialized
|
* No PHP session is actually started since a session can be initialized
|
||||||
* and shutdown only once per PHP execution cycle.
|
* and shutdown only once per PHP execution cycle.
|
||||||
*
|
*
|
||||||
* When doing functional testing, you should use MockFileSessionStorage instead.
|
* When doing functional testing, you should use MockFileStorage instead.
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
|
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class MockArraySessionStorage extends AbstractSessionStorage
|
class MockArrayStorage extends AbstractStorage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MockFileSessionStorage is used to mock sessions for
|
* MockFileStorage is used to mock sessions for
|
||||||
* functional testing when done in a single PHP process.
|
* functional testing when done in a single PHP process.
|
||||||
*
|
*
|
||||||
* No PHP session is actually started since a session can be initialized
|
* No PHP session is actually started since a session can be initialized
|
||||||
@ -20,7 +20,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage;
|
|||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class MockFileSessionStorage extends MockArraySessionStorage
|
class MockFileStorage extends MockArrayStorage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -33,7 +33,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
|
|||||||
* @param string $savePath Path of directory to save session files.
|
* @param string $savePath Path of directory to save session files.
|
||||||
* @param array $options Session options.
|
* @param array $options Session options.
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct($savePath = null, array $options = array())
|
public function __construct($savePath = null, array $options = array())
|
||||||
{
|
{
|
@ -12,13 +12,13 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeFileSessionStorage.
|
* NativeFileStorage.
|
||||||
*
|
*
|
||||||
* Native session handler using PHP's built in file storage.
|
* Native session handler using PHP's built in file storage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class NativeFileSessionStorage extends AbstractSessionStorage
|
class NativeFileStorage extends AbstractStorage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -31,7 +31,7 @@ class NativeFileSessionStorage extends AbstractSessionStorage
|
|||||||
* @param string $savePath Path of directory to save session files.
|
* @param string $savePath Path of directory to save session files.
|
||||||
* @param array $options Session configuration options.
|
* @param array $options Session configuration options.
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct($savePath = null, array $options = array())
|
public function __construct($savePath = null, array $options = array())
|
||||||
{
|
{
|
@ -12,13 +12,13 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeMemcacheSessionStorage.
|
* NativeMemcacheStorage.
|
||||||
*
|
*
|
||||||
* Session based on native PHP memcache database handler.
|
* Session based on native PHP memcache database handler.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class NativeMemcacheSessionStorage extends AbstractSessionStorage
|
class NativeMemcacheStorage extends AbstractStorage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -31,7 +31,7 @@ class NativeMemcacheSessionStorage extends AbstractSessionStorage
|
|||||||
* @param string $savePath Path of memcache server.
|
* @param string $savePath Path of memcache server.
|
||||||
* @param array $options Session configuration options.
|
* @param array $options Session configuration options.
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', array $options = array())
|
public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', array $options = array())
|
||||||
{
|
{
|
@ -12,13 +12,13 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeMemcachedSessionStorage.
|
* NativeMemcachedStorage.
|
||||||
*
|
*
|
||||||
* Session based on native PHP memcached database handler.
|
* Session based on native PHP memcached database handler.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class NativeMemcachedSessionStorage extends AbstractSessionStorage
|
class NativeMemcachedStorage extends AbstractStorage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -31,7 +31,7 @@ class NativeMemcachedSessionStorage extends AbstractSessionStorage
|
|||||||
* @param string $savePath Comma separated list of servers: e.g. memcache1.example.com:11211,memcache2.example.com:11211
|
* @param string $savePath Comma separated list of servers: e.g. memcache1.example.com:11211,memcache2.example.com:11211
|
||||||
* @param array $options Session configuration options.
|
* @param array $options Session configuration options.
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct($savePath = '127.0.0.1:11211', array $options = array())
|
public function __construct($savePath = '127.0.0.1:11211', array $options = array())
|
||||||
{
|
{
|
@ -12,13 +12,13 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeSqliteSessionStorage.
|
* NativeSqliteStorage.
|
||||||
*
|
*
|
||||||
* Session based on native PHP sqlite database handler.
|
* Session based on native PHP sqlite database handler.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class NativeSqliteSessionStorage extends AbstractSessionStorage
|
class NativeSqliteStorage extends AbstractStorage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -31,7 +31,7 @@ class NativeSqliteSessionStorage extends AbstractSessionStorage
|
|||||||
* @param string $dbPath Path to SQLite database file.
|
* @param string $dbPath Path to SQLite database file.
|
||||||
* @param array $options Session configuration options.
|
* @param array $options Session configuration options.
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct($dbPath, array $options = array())
|
public function __construct($dbPath, array $options = array())
|
||||||
{
|
{
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NullSessionStorage.
|
* NullStorage.
|
||||||
*
|
*
|
||||||
* Can be used in unit testing or in a sitation where persisted sessions are not desired.
|
* Can be used in unit testing or in a sitation where persisted sessions are not desired.
|
||||||
*
|
*
|
||||||
@ -20,7 +20,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage;
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class NullSessionStorage extends AbstractSessionStorage implements SessionSaveHandlerInterface
|
class NullStorage extends AbstractStorage implements SaveHandlerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
@ -12,12 +12,12 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PdoSessionStorage.
|
* PdoStorage.
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Michael Williams <michael.williams@funsational.com>
|
* @author Michael Williams <michael.williams@funsational.com>
|
||||||
*/
|
*/
|
||||||
class PdoSessionStorage extends AbstractSessionStorage implements SessionSaveHandlerInterface
|
class PdoStorage extends AbstractStorage implements SaveHandlerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* PDO instance.
|
* PDO instance.
|
||||||
@ -44,12 +44,12 @@ class PdoSessionStorage extends AbstractSessionStorage implements SessionSaveHan
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException When "db_table" option is not provided
|
* @throws \InvalidArgumentException When "db_table" option is not provided
|
||||||
*
|
*
|
||||||
* @see AbstractSessionStorage::__construct()
|
* @see AbstractStorage::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct(\PDO $pdo, array $dbOptions = array(), array $options = array())
|
public function __construct(\PDO $pdo, array $dbOptions = array(), array $options = array())
|
||||||
{
|
{
|
||||||
if (!array_key_exists('db_table', $dbOptions)) {
|
if (!array_key_exists('db_table', $dbOptions)) {
|
||||||
throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.');
|
throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoStorage.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pdo = $pdo;
|
$this->pdo = $pdo;
|
@ -52,7 +52,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage;
|
|||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
interface SessionSaveHandlerInterface
|
interface SaveHandlerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Open session.
|
* Open session.
|
@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
interface SessionStorageInterface
|
interface StorageInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Starts the session.
|
* Starts the session.
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Tests\Component\HttpFoundation;
|
namespace Symfony\Tests\Component\HttpFoundation;
|
||||||
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArrayStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@ -846,7 +846,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$request = new Request;
|
$request = new Request;
|
||||||
|
|
||||||
$this->assertFalse($request->hasSession());
|
$this->assertFalse($request->hasSession());
|
||||||
$request->setSession(new Session(new MockArraySessionStorage()));
|
$request->setSession(new Session(new MockArrayStorage()));
|
||||||
$this->assertTrue($request->hasSession());
|
$this->assertTrue($request->hasSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +857,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($request->hasPreviousSession());
|
$this->assertFalse($request->hasPreviousSession());
|
||||||
$request->cookies->set(session_name(), 'foo');
|
$request->cookies->set(session_name(), 'foo');
|
||||||
$this->assertFalse($request->hasPreviousSession());
|
$this->assertFalse($request->hasPreviousSession());
|
||||||
$request->setSession(new Session(new MockArraySessionStorage()));
|
$request->setSession(new Session(new MockArrayStorage()));
|
||||||
$this->assertTrue($request->hasPreviousSession());
|
$this->assertTrue($request->hasPreviousSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
|||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArrayStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SessionTest
|
* SessionTest
|
||||||
@ -28,7 +28,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
|||||||
class SessionTest extends \PHPUnit_Framework_TestCase
|
class SessionTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface
|
* @var \Symfony\Component\HttpFoundation\Session\Storage\StorageInterface
|
||||||
*/
|
*/
|
||||||
protected $storage;
|
protected $storage;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->storage = new MockArraySessionStorage();
|
$this->storage = new MockArrayStorage();
|
||||||
$this->session = new Session($this->storage, new AttributeBag(), new FlashBag());
|
$this->session = new Session($this->storage, new AttributeBag(), new FlashBag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,21 +2,21 @@
|
|||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\AbstractSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\AbstractStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\SessionSaveHandlerInterface;
|
use Symfony\Component\HttpFoundation\Session\Storage\SaveHandlerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn AbstractSessionStorage into something concrete because
|
* Turn AbstractStorage into something concrete because
|
||||||
* certain mocking features are broken in PHPUnit-Mock-Objects < 1.1.2
|
* certain mocking features are broken in PHPUnit-Mock-Objects < 1.1.2
|
||||||
* @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/73
|
* @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/73
|
||||||
*/
|
*/
|
||||||
class ConcreteSessionStorage extends AbstractSessionStorage
|
class ConcreteStorage extends AbstractStorage
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomHandlerSessionStorage extends AbstractSessionStorage implements SessionSaveHandlerInterface
|
class CustomHandlerStorage extends AbstractStorage implements SaveHandlerInterface
|
||||||
{
|
{
|
||||||
public function openSession($path, $id)
|
public function openSession($path, $id)
|
||||||
{
|
{
|
||||||
@ -44,7 +44,7 @@ class CustomHandlerSessionStorage extends AbstractSessionStorage implements Sess
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for AbstractSessionStorage.
|
* Test class for AbstractStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*
|
*
|
||||||
@ -52,14 +52,14 @@ class CustomHandlerSessionStorage extends AbstractSessionStorage implements Sess
|
|||||||
*
|
*
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class AbstractSessionStorageTest extends \PHPUnit_Framework_TestCase
|
class AbstractStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return AbstractSessionStorage
|
* @return AbstractStorage
|
||||||
*/
|
*/
|
||||||
protected function getStorage()
|
protected function getStorage()
|
||||||
{
|
{
|
||||||
$storage = new CustomHandlerSessionStorage();
|
$storage = new CustomHandlerStorage();
|
||||||
$storage->registerBag(new AttributeBag);
|
$storage->registerBag(new AttributeBag);
|
||||||
|
|
||||||
return $storage;
|
return $storage;
|
||||||
@ -115,13 +115,13 @@ class AbstractSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testCustomSaveHandlers()
|
public function testCustomSaveHandlers()
|
||||||
{
|
{
|
||||||
$storage = new CustomHandlerSessionStorage();
|
$storage = new CustomHandlerStorage();
|
||||||
$this->assertEquals('user', ini_get('session.save_handler'));
|
$this->assertEquals('user', ini_get('session.save_handler'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNativeSaveHandlers()
|
public function testNativeSaveHandlers()
|
||||||
{
|
{
|
||||||
$storage = new ConcreteSessionStorage();
|
$storage = new ConcreteStorage();
|
||||||
$this->assertNotEquals('user', ini_get('session.save_handler'));
|
$this->assertNotEquals('user', ini_get('session.save_handler'));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,20 +2,20 @@
|
|||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArrayStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for MockArraySessionStorage.
|
* Test class for MockArrayStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class MockArraySessionStorageTest extends \PHPUnit_Framework_TestCase
|
class MockArrayStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var MockArraySessionStorage
|
* @var MockArrayStorage
|
||||||
*/
|
*/
|
||||||
private $storage;
|
private $storage;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ class MockArraySessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->flashes->getStorageKey() => array('notice' => 'hello'),
|
$this->flashes->getStorageKey() => array('notice' => 'hello'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->storage = new MockArraySessionStorage();
|
$this->storage = new MockArrayStorage();
|
||||||
$this->storage->registerBag($this->flashes);
|
$this->storage->registerBag($this->flashes);
|
||||||
$this->storage->registerBag($this->attributes);
|
$this->storage->registerBag($this->attributes);
|
||||||
$this->storage->setSessionData($this->data);
|
$this->storage->setSessionData($this->data);
|
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
namespace Symfony\Test\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Test\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockFileStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for MockFileSessionStorage.
|
* Test class for MockFileStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*/
|
*/
|
||||||
class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase
|
class MockFileStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -19,7 +19,7 @@ class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
private $sessionDir;
|
private $sessionDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FileMockSessionStorage
|
* @var FileMockStorage
|
||||||
*/
|
*/
|
||||||
protected $storage;
|
protected $storage;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
private function getStorage(array $options = array())
|
private function getStorage(array $options = array())
|
||||||
{
|
{
|
||||||
$storage = new MockFileSessionStorage($this->sessionDir, $options);
|
$storage = new MockFileStorage($this->sessionDir, $options);
|
||||||
$storage->registerBag(new FlashBag);
|
$storage->registerBag(new FlashBag);
|
||||||
$storage->registerBag(new AttributeBag);
|
$storage->registerBag(new AttributeBag);
|
||||||
|
|
@ -2,22 +2,22 @@
|
|||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\NativeFileSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\NativeFileStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for NativeFileSessionStorage.
|
* Test class for NativeFileStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class NativeFileSessionStorageTest extends \PHPUnit_Framework_TestCase
|
class NativeFileStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testSaveHandlers()
|
public function testSaveHandlers()
|
||||||
{
|
{
|
||||||
$storage = new NativeFileSessionStorage(sys_get_temp_dir(), array('name' => 'TESTING'));
|
$storage = new NativeFileStorage(sys_get_temp_dir(), array('name' => 'TESTING'));
|
||||||
$this->assertEquals('files', ini_get('session.save_handler'));
|
$this->assertEquals('files', ini_get('session.save_handler'));
|
||||||
$this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path'));
|
$this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path'));
|
||||||
$this->assertEquals('TESTING', ini_get('session.name'));
|
$this->assertEquals('TESTING', ini_get('session.name'));
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\NativeMemcacheSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\NativeMemcacheStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for NativeMemcacheSessionStorage.
|
* Test class for NativeMemcacheStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class NativeMemcacheSessionStorageTest extends \PHPUnit_Framework_TestCase
|
class NativeMemcacheStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testSaveHandlers()
|
public function testSaveHandlers()
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ class NativeMemcacheSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->markTestSkipped('Skipped tests SQLite extension is not present');
|
$this->markTestSkipped('Skipped tests SQLite extension is not present');
|
||||||
}
|
}
|
||||||
|
|
||||||
$storage = new NativeMemcacheSessionStorage('tcp://127.0.0.1:11211?persistent=0', array('name' => 'TESTING'));
|
$storage = new NativeMemcacheStorage('tcp://127.0.0.1:11211?persistent=0', array('name' => 'TESTING'));
|
||||||
$this->assertEquals('memcache', ini_get('session.save_handler'));
|
$this->assertEquals('memcache', ini_get('session.save_handler'));
|
||||||
$this->assertEquals('tcp://127.0.0.1:11211?persistent=0', ini_get('session.save_path'));
|
$this->assertEquals('tcp://127.0.0.1:11211?persistent=0', ini_get('session.save_path'));
|
||||||
$this->assertEquals('TESTING', ini_get('session.name'));
|
$this->assertEquals('TESTING', ini_get('session.name'));
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\NativeMemcachedSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\NativeMemcachedStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for NativeMemcachedSessionStorage.
|
* Test class for NativeMemcachedStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class NativeMemcachedSessionStorageTest extends \PHPUnit_Framework_TestCase
|
class NativeMemcachedStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testSaveHandlers()
|
public function testSaveHandlers()
|
||||||
{
|
{
|
||||||
@ -24,7 +24,7 @@ class NativeMemcachedSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
// test takes too long if memcached server is not running
|
// test takes too long if memcached server is not running
|
||||||
ini_set('memcached.sess_locking', '0');
|
ini_set('memcached.sess_locking', '0');
|
||||||
|
|
||||||
$storage = new NativeMemcachedSessionStorage('127.0.0.1:11211', array('name' => 'TESTING'));
|
$storage = new NativeMemcachedStorage('127.0.0.1:11211', array('name' => 'TESTING'));
|
||||||
|
|
||||||
$this->assertEquals('memcached', ini_get('session.save_handler'));
|
$this->assertEquals('memcached', ini_get('session.save_handler'));
|
||||||
$this->assertEquals('127.0.0.1:11211', ini_get('session.save_path'));
|
$this->assertEquals('127.0.0.1:11211', ini_get('session.save_path'));
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\NativeSqliteSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\NativeSqliteStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for NativeSqliteSessionStorage.
|
* Test class for NativeSqliteStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class NativeSqliteSessionStorageTest extends \PHPUnit_Framework_TestCase
|
class NativeSqliteStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testSaveHandlers()
|
public function testSaveHandlers()
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ class NativeSqliteSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->markTestSkipped('Skipped tests SQLite extension is not present');
|
$this->markTestSkipped('Skipped tests SQLite extension is not present');
|
||||||
}
|
}
|
||||||
|
|
||||||
$storage = new NativeSqliteSessionStorage(sys_get_temp_dir().'/sqlite.db', array('name' => 'TESTING'));
|
$storage = new NativeSqliteStorage(sys_get_temp_dir().'/sqlite.db', array('name' => 'TESTING'));
|
||||||
$this->assertEquals('sqlite', ini_get('session.save_handler'));
|
$this->assertEquals('sqlite', ini_get('session.save_handler'));
|
||||||
$this->assertEquals(sys_get_temp_dir().'/sqlite.db', ini_get('session.save_path'));
|
$this->assertEquals(sys_get_temp_dir().'/sqlite.db', ini_get('session.save_path'));
|
||||||
$this->assertEquals('TESTING', ini_get('session.name'));
|
$this->assertEquals('TESTING', ini_get('session.name'));
|
@ -1,28 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\NullSessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\NullStorage;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for NullSessionStorage.
|
* Test class for NullStorage.
|
||||||
*
|
*
|
||||||
* @author Drak <drak@zikula.org>
|
* @author Drak <drak@zikula.org>
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class NullSessionStorageTest extends \PHPUnit_Framework_TestCase
|
class NullStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testSaveHandlers()
|
public function testSaveHandlers()
|
||||||
{
|
{
|
||||||
$storage = new NullSessionStorage();
|
$storage = new NullStorage();
|
||||||
$this->assertEquals('user', ini_get('session.save_handler'));
|
$this->assertEquals('user', ini_get('session.save_handler'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSession()
|
public function testSession()
|
||||||
{
|
{
|
||||||
session_id('nullsessionstorage');
|
session_id('nullsessionstorage');
|
||||||
$storage = new NullSessionStorage();
|
$storage = new NullStorage();
|
||||||
$session = new Session($storage);
|
$session = new Session($storage);
|
||||||
$this->assertNull($session->get('something'));
|
$this->assertNull($session->get('something'));
|
||||||
$session->set('something', 'unique');
|
$session->set('something', 'unique');
|
||||||
@ -32,7 +32,7 @@ class NullSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testNothingIsPersisted()
|
public function testNothingIsPersisted()
|
||||||
{
|
{
|
||||||
session_id('nullsessionstorage');
|
session_id('nullsessionstorage');
|
||||||
$storage = new NullSessionStorage();
|
$storage = new NullStorage();
|
||||||
$session = new Session($storage);
|
$session = new Session($storage);
|
||||||
$session->start();
|
$session->start();
|
||||||
$this->assertEquals('nullsessionstorage', $session->getId());
|
$this->assertEquals('nullsessionstorage', $session->getId());
|
@ -5,7 +5,7 @@ namespace Symfony\Test\Component\Security\Http\Firewall;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArrayStorage;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||||
@ -63,7 +63,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function runSessionOnKernelResponse($newToken, $original = null)
|
protected function runSessionOnKernelResponse($newToken, $original = null)
|
||||||
{
|
{
|
||||||
$session = new Session(new MockArraySessionStorage());
|
$session = new Session(new MockArrayStorage());
|
||||||
|
|
||||||
if ($original !== null) {
|
if ($original !== null) {
|
||||||
$session->set('_security_session', $original);
|
$session->set('_security_session', $original);
|
||||||
|
Reference in New Issue
Block a user