summaryrefslogtreecommitdiff
path: root/tests/units/Core/Session
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Core/Session')
-rw-r--r--tests/units/Core/Session/FlashMessageTest.php23
-rw-r--r--tests/units/Core/Session/SessionStorageTest.php38
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/units/Core/Session/FlashMessageTest.php b/tests/units/Core/Session/FlashMessageTest.php
new file mode 100644
index 00000000..25361343
--- /dev/null
+++ b/tests/units/Core/Session/FlashMessageTest.php
@@ -0,0 +1,23 @@
+<?php
+
+require_once __DIR__.'/../../Base.php';
+
+use Kanboard\Core\Session\FlashMessage;
+
+class FlashMessageTest extends Base
+{
+ public function testMessage()
+ {
+ $flash = new FlashMessage($this->container);
+
+ $flash->success('my message');
+ $this->assertEquals('my message', $flash->getMessage('success'));
+ $this->assertEmpty($flash->getMessage('success'));
+
+ $flash->failure('my error message');
+ $this->assertEquals('my error message', $flash->getMessage('failure'));
+ $this->assertEmpty($flash->getMessage('failure'));
+
+ $this->assertEmpty($flash->getMessage('not found'));
+ }
+}
diff --git a/tests/units/Core/Session/SessionStorageTest.php b/tests/units/Core/Session/SessionStorageTest.php
new file mode 100644
index 00000000..62495e5e
--- /dev/null
+++ b/tests/units/Core/Session/SessionStorageTest.php
@@ -0,0 +1,38 @@
+<?php
+
+require_once __DIR__.'/../../Base.php';
+
+use Kanboard\Core\Session\SessionStorage;
+
+class SessionStorageTest extends Base
+{
+ public function testNotPersistentStorage()
+ {
+ $storage = new SessionStorage();
+ $storage->something = array('a' => 'b');
+ $this->assertEquals(array('a' => 'b'), $storage->something);
+ $this->assertTrue(isset($storage->something));
+ $this->assertFalse(isset($storage->something->x));
+ $this->assertFalse(isset($storage->notFound));
+ $this->assertFalse(isset($storage->notFound->x));
+ $this->assertFalse(isset($storage->notFound['x']));
+ }
+
+ public function testPersistentStorage()
+ {
+ $session = array('d' => 'e');
+
+ $storage = new SessionStorage();
+ $storage->setStorage($session);
+ $storage->something = array('a' => 'b');
+
+ $this->assertEquals(array('a' => 'b'), $storage->something);
+ $this->assertEquals('e', $storage->d);
+
+ $storage->something['a'] = 'c';
+ $this->assertEquals('c', $storage->something['a']);
+
+ $storage = null;
+ $this->assertEquals(array('something' => array('a' => 'c'), 'd' => 'e'), $session);
+ }
+}