summaryrefslogtreecommitdiff
path: root/tests/units/UserSessionTest.php
blob: 45f1bfde9360b6649736fef4bf17f6bdb5b0b700 (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
39
40
41
42
43
44
45
<?php

require_once __DIR__.'/Base.php';

use Core\Session;
use Model\UserSession;

class UserSessionTest extends Base
{
    public function testIsAdmin()
    {
        $s = new Session;
        $us = new UserSession($this->container);

        $this->assertFalse($us->isAdmin());

        $s['user'] = array();
        $this->assertFalse($us->isAdmin());

        $s['user'] = array('is_admin' => '1');
        $this->assertFalse($us->isAdmin());

        $s['user'] = array('is_admin' => false);
        $this->assertFalse($us->isAdmin());

        $s['user'] = array('is_admin' => '2');
        $this->assertFalse($us->isAdmin());

        $s['user'] = array('is_admin' => true);
        $this->assertTrue($us->isAdmin());
    }

    public function testLastSeenProject()
    {
        $us = new UserSession($this->container);

        $this->assertEquals(0, $us->getLastSeenProjectId());

        $us->storeLastSeenProjectId(33);
        $this->assertEquals(33, $us->getLastSeenProjectId());

        $us->storeLastSeenProjectId(66);
        $this->assertEquals(66, $us->getLastSeenProjectId());
    }
}