Remove method write() from Icinga\Web\Session\SessionNamespace
This commit is contained in:
parent
c00dbf9f46
commit
6f988cb94c
|
@ -121,7 +121,7 @@ class PhpSession extends Session
|
|||
|
||||
foreach ($_SESSION as $key => $value) {
|
||||
if (strpos($key, self::NAMESPACE_PREFIX) === 0) {
|
||||
$namespace = new SessionNamespace($this);
|
||||
$namespace = new SessionNamespace();
|
||||
$namespace->setAll($value);
|
||||
$this->namespaces[substr($key, strlen(self::NAMESPACE_PREFIX))] = $namespace;
|
||||
} else {
|
||||
|
|
|
@ -75,7 +75,7 @@ abstract class Session extends SessionNamespace
|
|||
unset($this->removedNamespaces[array_search($identifier, $this->removedNamespaces)]);
|
||||
}
|
||||
|
||||
$this->namespaces[$identifier] = new SessionNamespace($this);
|
||||
$this->namespaces[$identifier] = new SessionNamespace();
|
||||
}
|
||||
|
||||
return $this->namespaces[$identifier];
|
||||
|
|
|
@ -14,13 +14,6 @@ use IteratorAggregate;
|
|||
*/
|
||||
class SessionNamespace implements IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* The session this namespace is associated to
|
||||
*
|
||||
* @var Session
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* The actual values stored in this container
|
||||
*
|
||||
|
@ -35,16 +28,6 @@ class SessionNamespace implements IteratorAggregate
|
|||
*/
|
||||
protected $removed = array();
|
||||
|
||||
/**
|
||||
* Create a new session namespace
|
||||
*
|
||||
* @param Session $session The session this namespace is associated to
|
||||
*/
|
||||
public function __construct(Session $session = null)
|
||||
{
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an iterator for all values in this namespace
|
||||
*
|
||||
|
@ -197,18 +180,6 @@ class SessionNamespace implements IteratorAggregate
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the session this namespace is associated to
|
||||
*/
|
||||
public function write()
|
||||
{
|
||||
if (!$this->session) {
|
||||
throw new IcingaException('Cannot save, session not set');
|
||||
}
|
||||
|
||||
$this->session->write();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the session namespace has been changed
|
||||
*
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
namespace Tests\Icinga\Web\Session;
|
||||
|
||||
use Mockery;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Web\Session\SessionNamespace;
|
||||
|
||||
|
@ -85,26 +84,4 @@ class SessionNamespaceTest extends BaseTestCase
|
|||
$this->assertEquals($value, $values[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Icinga\Exception\IcingaException
|
||||
* @expectedExceptionMessage Cannot save, session not set
|
||||
*/
|
||||
public function testInvalidParentWrite()
|
||||
{
|
||||
$ns = new SessionNamespace();
|
||||
$ns->write();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether it is possible to write a namespace's parent
|
||||
*/
|
||||
public function testValidParentWrite()
|
||||
{
|
||||
$sessionMock = Mockery::mock('Icinga\Web\Session\Session');
|
||||
$sessionMock->shouldReceive('write')->atLeast()->times(1);
|
||||
|
||||
$ns = new SessionNamespace($sessionMock);
|
||||
$ns->write();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue