summaryrefslogtreecommitdiff
path: root/tests/units/Core/Session/SessionStorageTest.php
blob: 62495e5eb1e6fcfe5653620cd8512974489dac9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);
    }
}