exception when registering bags for started sessions
This commit is contained in:
parent
ce60be5729
commit
c4a5b67a5a
@ -260,6 +260,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
*/
|
||||
public function registerBag(SessionBagInterface $bag)
|
||||
{
|
||||
if ($this->started) {
|
||||
throw new \LogicException('Cannot register a bag when the session is already started.');
|
||||
}
|
||||
|
||||
$this->bags[$bag->getName()] = $bag;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,16 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$storage->getBag('non_existing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testRegisterBagForAStartedSessionThrowsException()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
$storage->start();
|
||||
$storage->registerBag(new AttributeBag());
|
||||
}
|
||||
|
||||
public function testGetId()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
|
Reference in New Issue
Block a user