summaryrefslogtreecommitdiff
path: root/tests/units/Model/UserSessionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Model/UserSessionTest.php')
-rw-r--r--tests/units/Model/UserSessionTest.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/units/Model/UserSessionTest.php b/tests/units/Model/UserSessionTest.php
new file mode 100644
index 00000000..31072e6a
--- /dev/null
+++ b/tests/units/Model/UserSessionTest.php
@@ -0,0 +1,32 @@
+<?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());
+ }
+}