From 6f988cb94cbc26f676db93c7b663b5efe365f62a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Sep 2014 10:43:52 +0200 Subject: [PATCH] Remove method write() from Icinga\Web\Session\SessionNamespace --- library/Icinga/Web/Session/PhpSession.php | 2 +- library/Icinga/Web/Session/Session.php | 2 +- .../Icinga/Web/Session/SessionNamespace.php | 29 ------------------- .../Web/Session/SessionNamespaceTest.php | 23 --------------- 4 files changed, 2 insertions(+), 54 deletions(-) diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php index 65f940a13..d0d44530c 100644 --- a/library/Icinga/Web/Session/PhpSession.php +++ b/library/Icinga/Web/Session/PhpSession.php @@ -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 { diff --git a/library/Icinga/Web/Session/Session.php b/library/Icinga/Web/Session/Session.php index 0991ec708..ab73dcac7 100644 --- a/library/Icinga/Web/Session/Session.php +++ b/library/Icinga/Web/Session/Session.php @@ -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]; diff --git a/library/Icinga/Web/Session/SessionNamespace.php b/library/Icinga/Web/Session/SessionNamespace.php index 76837adda..bb67838d6 100644 --- a/library/Icinga/Web/Session/SessionNamespace.php +++ b/library/Icinga/Web/Session/SessionNamespace.php @@ -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 * diff --git a/test/php/library/Icinga/Web/Session/SessionNamespaceTest.php b/test/php/library/Icinga/Web/Session/SessionNamespaceTest.php index 11dcb23ec..90ad6326b 100644 --- a/test/php/library/Icinga/Web/Session/SessionNamespaceTest.php +++ b/test/php/library/Icinga/Web/Session/SessionNamespaceTest.php @@ -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(); - } }