Store PHP sessions in the database
This commit is contained in:
committed by
Frédéric Guillot
parent
421531bd4f
commit
ccd177ada6
@@ -13,7 +13,7 @@ class CommentCreationMoveTaskColumnTest extends Base
|
||||
{
|
||||
public function testSuccess()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$commentModel = new CommentModel($this->container);
|
||||
|
||||
@@ -13,7 +13,7 @@ class TaskAssignCurrentUserColumnTest extends Base
|
||||
{
|
||||
public function testChangeUser()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
@@ -43,7 +43,7 @@ class TaskAssignCurrentUserColumnTest extends Base
|
||||
|
||||
public function testWithWrongColumn()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
|
||||
@@ -13,7 +13,7 @@ class TaskAssignCurrentUserTest extends Base
|
||||
{
|
||||
public function testChangeUser()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
|
||||
@@ -49,7 +49,7 @@ class ApiAccessTokenAuthTest extends Base
|
||||
|
||||
public function testAuthenticateWithToken()
|
||||
{
|
||||
$this->container['sessionStorage']->scope = 'API';
|
||||
$_SESSION['scope'] = 'API';
|
||||
|
||||
$provider = new ApiAccessTokenAuth($this->container);
|
||||
$userModel = new UserModel($this->container);
|
||||
|
||||
@@ -48,15 +48,15 @@ class DatabaseAuthTest extends Base
|
||||
|
||||
$this->assertEquals(2, $userModel->create(array('username' => 'foobar')));
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 2);
|
||||
$_SESSION['user'] = array('id' => 2);
|
||||
$this->assertTrue($provider->isValidSession());
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 3);
|
||||
$_SESSION['user'] = array('id' => 3);
|
||||
$this->assertFalse($provider->isValidSession());
|
||||
|
||||
$this->assertTrue($userModel->disable(2));
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 2);
|
||||
$_SESSION['user'] = array('id' => 2);
|
||||
$this->assertFalse($provider->isValidSession());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class ReverseProxyAuthTest extends Base
|
||||
->method('getRemoteUser')
|
||||
->will($this->returnValue('admin'));
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'username' => 'admin'
|
||||
);
|
||||
|
||||
@@ -69,7 +69,7 @@ class ReverseProxyAuthTest extends Base
|
||||
->method('getRemoteUser')
|
||||
->will($this->returnValue('foobar'));
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'username' => 'admin'
|
||||
);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use SimpleLogger\Logger;
|
||||
use Kanboard\Core\Session\FlashMessage;
|
||||
use Kanboard\Core\Session\SessionStorage;
|
||||
use Kanboard\ServiceProvider\ActionProvider;
|
||||
|
||||
abstract class Base extends PHPUnit_Framework_TestCase
|
||||
@@ -24,6 +23,7 @@ abstract class Base extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
date_default_timezone_set('UTC');
|
||||
$_SESSION = array();
|
||||
|
||||
if (DB_DRIVER === 'mysql') {
|
||||
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
|
||||
@@ -86,7 +86,6 @@ abstract class Base extends PHPUnit_Framework_TestCase
|
||||
->setMethods(array('put', 'moveFile', 'remove', 'moveUploadedFile'))
|
||||
->getMock();
|
||||
|
||||
$this->container['sessionStorage'] = new SessionStorage;
|
||||
$this->container->register(new ActionProvider);
|
||||
|
||||
$this->container['flash'] = function ($c) {
|
||||
|
||||
@@ -116,7 +116,7 @@ class ActionManagerTest extends Base
|
||||
|
||||
public function testAttachEventsWithLoggedUser()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$projectUserRoleModel = new ProjectUserRoleModel($this->container);
|
||||
|
||||
@@ -56,7 +56,7 @@ class AuthenticationManagerTest extends Base
|
||||
$authManager = new AuthenticationManager($this->container);
|
||||
$authManager->register(new DatabaseAuth($this->container));
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1, 'username' => 'test');
|
||||
|
||||
$this->assertTrue($this->container['userSession']->isLogged());
|
||||
$this->assertTrue($authManager->checkCurrentSession());
|
||||
@@ -67,7 +67,7 @@ class AuthenticationManagerTest extends Base
|
||||
$authManager = new AuthenticationManager($this->container);
|
||||
$authManager->register(new DatabaseAuth($this->container));
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 2);
|
||||
$_SESSION['user'] = array('id' => 42, 'username' => 'test');
|
||||
|
||||
$this->assertTrue($this->container['userSession']->isLogged());
|
||||
$this->assertFalse($authManager->checkCurrentSession());
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
public function testFlush()
|
||||
{
|
||||
$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->flush();
|
||||
|
||||
$this->assertFalse(isset($storage->d));
|
||||
$this->assertFalse(isset($storage->something));
|
||||
|
||||
$storage->foo = 'bar';
|
||||
|
||||
$storage = null;
|
||||
$this->assertEquals(array('foo' => 'bar'), $session);
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ class UserProfileTest extends Base
|
||||
$user = new DatabaseUserProvider(array('id' => 1));
|
||||
|
||||
$this->assertTrue($userProfile->initialize($user));
|
||||
$this->assertNotEmpty($this->container['sessionStorage']->user);
|
||||
$this->assertEquals('admin', $this->container['sessionStorage']->user['username']);
|
||||
$this->assertNotEmpty($_SESSION['user']);
|
||||
$this->assertEquals('admin', $_SESSION['user']['username']);
|
||||
}
|
||||
|
||||
public function testInitializeLocalUserNotFound()
|
||||
@@ -25,7 +25,7 @@ class UserProfileTest extends Base
|
||||
$user = new DatabaseUserProvider(array('id' => 2));
|
||||
|
||||
$this->assertFalse($userProfile->initialize($user));
|
||||
$this->assertFalse(isset($this->container['sessionStorage']->user));
|
||||
$this->assertFalse(isset($_SESSION['user']));
|
||||
}
|
||||
|
||||
public function testInitializeRemoteUser()
|
||||
@@ -34,17 +34,17 @@ class UserProfileTest extends Base
|
||||
$user = new LdapUserProvider('ldapId', 'bob', 'Bob', '', Role::APP_MANAGER, array());
|
||||
|
||||
$this->assertTrue($userProfile->initialize($user));
|
||||
$this->assertNotEmpty($this->container['sessionStorage']->user);
|
||||
$this->assertEquals(2, $this->container['sessionStorage']->user['id']);
|
||||
$this->assertEquals('bob', $this->container['sessionStorage']->user['username']);
|
||||
$this->assertEquals(Role::APP_MANAGER, $this->container['sessionStorage']->user['role']);
|
||||
$this->assertNotEmpty($_SESSION['user']);
|
||||
$this->assertEquals(2, $_SESSION['user']['id']);
|
||||
$this->assertEquals('bob', $_SESSION['user']['username']);
|
||||
$this->assertEquals(Role::APP_MANAGER, $_SESSION['user']['role']);
|
||||
|
||||
$user = new LdapUserProvider('ldapId', 'bob', 'Bob', '', Role::APP_MANAGER, array());
|
||||
|
||||
$this->assertTrue($userProfile->initialize($user));
|
||||
$this->assertNotEmpty($this->container['sessionStorage']->user);
|
||||
$this->assertEquals(2, $this->container['sessionStorage']->user['id']);
|
||||
$this->assertEquals('bob', $this->container['sessionStorage']->user['username']);
|
||||
$this->assertNotEmpty($_SESSION['user']);
|
||||
$this->assertEquals(2, $_SESSION['user']['id']);
|
||||
$this->assertEquals('bob', $_SESSION['user']['username']);
|
||||
}
|
||||
|
||||
public function testAssignRemoteUser()
|
||||
@@ -53,11 +53,11 @@ class UserProfileTest extends Base
|
||||
$user = new LdapUserProvider('ldapId', 'bob', 'Bob', '', Role::APP_MANAGER, array());
|
||||
|
||||
$this->assertTrue($userProfile->assign(1, $user));
|
||||
$this->assertNotEmpty($this->container['sessionStorage']->user);
|
||||
$this->assertEquals(1, $this->container['sessionStorage']->user['id']);
|
||||
$this->assertEquals('admin', $this->container['sessionStorage']->user['username']);
|
||||
$this->assertEquals('Bob', $this->container['sessionStorage']->user['name']);
|
||||
$this->assertEquals('', $this->container['sessionStorage']->user['email']);
|
||||
$this->assertEquals(Role::APP_MANAGER, $this->container['sessionStorage']->user['role']);
|
||||
$this->assertNotEmpty($_SESSION['user']);
|
||||
$this->assertEquals(1, $_SESSION['user']['id']);
|
||||
$this->assertEquals('admin', $_SESSION['user']['username']);
|
||||
$this->assertEquals('Bob', $_SESSION['user']['name']);
|
||||
$this->assertEquals('', $_SESSION['user']['email']);
|
||||
$this->assertEquals(Role::APP_MANAGER, $_SESSION['user']['role']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ class UserSessionTest extends Base
|
||||
{
|
||||
public function testInitialize()
|
||||
{
|
||||
$us = new UserSession($this->container);
|
||||
|
||||
$userSession = new UserSession($this->container);
|
||||
$user = array(
|
||||
'id' => '123',
|
||||
'username' => 'john',
|
||||
@@ -23,101 +22,97 @@ class UserSessionTest extends Base
|
||||
'role' => Role::APP_MANAGER,
|
||||
);
|
||||
|
||||
$us->initialize($user);
|
||||
$userSession->initialize($user);
|
||||
|
||||
$session = $this->container['sessionStorage']->getAll();
|
||||
$this->assertNotEmpty($_SESSION);
|
||||
$this->assertEquals(123, $_SESSION['user']['id']);
|
||||
$this->assertEquals('john', $_SESSION['user']['username']);
|
||||
$this->assertEquals(Role::APP_MANAGER, $_SESSION['user']['role']);
|
||||
$this->assertFalse($_SESSION['user']['is_ldap_user']);
|
||||
$this->assertFalse($_SESSION['user']['twofactor_activated']);
|
||||
$this->assertArrayNotHasKey('password', $_SESSION['user']);
|
||||
$this->assertArrayNotHasKey('twofactor_secret', $_SESSION['user']);
|
||||
$this->assertArrayNotHasKey('is_admin', $_SESSION['user']);
|
||||
$this->assertArrayNotHasKey('is_project_admin', $_SESSION['user']);
|
||||
|
||||
$this->assertNotEmpty($session);
|
||||
$this->assertEquals(123, $session['user']['id']);
|
||||
$this->assertEquals('john', $session['user']['username']);
|
||||
$this->assertEquals(Role::APP_MANAGER, $session['user']['role']);
|
||||
$this->assertFalse($session['user']['is_ldap_user']);
|
||||
$this->assertFalse($session['user']['twofactor_activated']);
|
||||
$this->assertArrayNotHasKey('password', $session['user']);
|
||||
$this->assertArrayNotHasKey('twofactor_secret', $session['user']);
|
||||
$this->assertArrayNotHasKey('is_admin', $session['user']);
|
||||
$this->assertArrayNotHasKey('is_project_admin', $session['user']);
|
||||
|
||||
$this->assertEquals('john', $us->getUsername());
|
||||
$this->assertEquals('john', $userSession->getUsername());
|
||||
}
|
||||
|
||||
public function testGetId()
|
||||
{
|
||||
$us = new UserSession($this->container);
|
||||
$userSession = new UserSession($this->container);
|
||||
|
||||
$this->assertEquals(0, $us->getId());
|
||||
$this->assertEquals(0, $userSession->getId());
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 2);
|
||||
$this->assertEquals(2, $us->getId());
|
||||
$_SESSION['user'] = array('id' => 2);
|
||||
$this->assertEquals(2, $userSession->getId());
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => '2');
|
||||
$this->assertEquals(2, $us->getId());
|
||||
$_SESSION['user'] = array('id' => '2');
|
||||
$this->assertEquals(2, $userSession->getId());
|
||||
}
|
||||
|
||||
public function testIsLogged()
|
||||
{
|
||||
$us = new UserSession($this->container);
|
||||
$userSession = new UserSession($this->container);
|
||||
$this->assertFalse($userSession->isLogged());
|
||||
|
||||
$this->assertFalse($us->isLogged());
|
||||
$_SESSION['user'] = array();
|
||||
$this->assertFalse($userSession->isLogged());
|
||||
|
||||
$this->container['sessionStorage']->user = array();
|
||||
$this->assertFalse($us->isLogged());
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$this->assertTrue($us->isLogged());
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
$this->assertTrue($userSession->isLogged());
|
||||
}
|
||||
|
||||
public function testIsAdmin()
|
||||
{
|
||||
$us = new UserSession($this->container);
|
||||
$userSession = new UserSession($this->container);
|
||||
$this->assertFalse($userSession->isAdmin());
|
||||
|
||||
$this->assertFalse($us->isAdmin());
|
||||
$_SESSION['user'] = array('role' => Role::APP_ADMIN);
|
||||
$this->assertTrue($userSession->isAdmin());
|
||||
|
||||
$this->container['sessionStorage']->user = array('role' => Role::APP_ADMIN);
|
||||
$this->assertTrue($us->isAdmin());
|
||||
$_SESSION['user'] = array('role' => Role::APP_USER);
|
||||
$this->assertFalse($userSession->isAdmin());
|
||||
|
||||
$this->container['sessionStorage']->user = array('role' => Role::APP_USER);
|
||||
$this->assertFalse($us->isAdmin());
|
||||
|
||||
$this->container['sessionStorage']->user = array('role' => '');
|
||||
$this->assertFalse($us->isAdmin());
|
||||
$_SESSION['user'] = array('role' => '');
|
||||
$this->assertFalse($userSession->isAdmin());
|
||||
}
|
||||
|
||||
public function testFilters()
|
||||
{
|
||||
$us = new UserSession($this->container);
|
||||
$this->assertEquals('status:open', $us->getFilters(1));
|
||||
$userSession = new UserSession($this->container);
|
||||
$this->assertEquals('status:open', $userSession->getFilters(1));
|
||||
|
||||
$us->setFilters(1, 'assignee:me');
|
||||
$this->assertEquals('assignee:me', $us->getFilters(1));
|
||||
$userSession->setFilters(1, 'assignee:me');
|
||||
$this->assertEquals('assignee:me', $userSession->getFilters(1));
|
||||
|
||||
$this->assertEquals('status:open', $us->getFilters(2));
|
||||
$this->assertEquals('status:open', $userSession->getFilters(2));
|
||||
|
||||
$us->setFilters(2, 'assignee:bob');
|
||||
$this->assertEquals('assignee:bob', $us->getFilters(2));
|
||||
$userSession->setFilters(2, 'assignee:bob');
|
||||
$this->assertEquals('assignee:bob', $userSession->getFilters(2));
|
||||
}
|
||||
|
||||
public function testPostAuthentication()
|
||||
{
|
||||
$us = new UserSession($this->container);
|
||||
$this->assertFalse($us->isPostAuthenticationValidated());
|
||||
$userSession = new UserSession($this->container);
|
||||
$this->assertFalse($userSession->isPostAuthenticationValidated());
|
||||
|
||||
$this->container['sessionStorage']->postAuthenticationValidated = false;
|
||||
$this->assertFalse($us->isPostAuthenticationValidated());
|
||||
$_SESSION['postAuthenticationValidated'] = false;
|
||||
$this->assertFalse($userSession->isPostAuthenticationValidated());
|
||||
|
||||
$us->validatePostAuthentication();
|
||||
$this->assertTrue($us->isPostAuthenticationValidated());
|
||||
$userSession->validatePostAuthentication();
|
||||
$this->assertTrue($userSession->isPostAuthenticationValidated());
|
||||
|
||||
$this->container['sessionStorage']->user = array();
|
||||
$this->assertFalse($us->hasPostAuthentication());
|
||||
$_SESSION['user'] = array();
|
||||
$this->assertFalse($userSession->hasPostAuthentication());
|
||||
|
||||
$this->container['sessionStorage']->user = array('twofactor_activated' => false);
|
||||
$this->assertFalse($us->hasPostAuthentication());
|
||||
$_SESSION['user'] = array('twofactor_activated' => false);
|
||||
$this->assertFalse($userSession->hasPostAuthentication());
|
||||
|
||||
$this->container['sessionStorage']->user = array('twofactor_activated' => true);
|
||||
$this->assertTrue($us->hasPostAuthentication());
|
||||
$_SESSION['user'] = array('twofactor_activated' => true);
|
||||
$this->assertTrue($userSession->hasPostAuthentication());
|
||||
|
||||
$us->disablePostAuthentication();
|
||||
$this->assertFalse($us->hasPostAuthentication());
|
||||
$userSession->disablePostAuthentication();
|
||||
$this->assertFalse($userSession->hasPostAuthentication());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
$userModel = new UserModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -44,7 +44,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
$userModel = new UserModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -64,7 +64,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$userModel = new UserModel($this->container);
|
||||
$projectRoleModel = new ProjectRoleModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -88,7 +88,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container);
|
||||
$columnRestrictionModel = new ColumnRestrictionModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -117,7 +117,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$taskFinderModel = new TaskFinderModel($this->container);
|
||||
$projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -145,7 +145,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
$taskFinderModel = new TaskFinderModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -172,7 +172,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$taskFinderModel = new TaskFinderModel($this->container);
|
||||
$projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -200,7 +200,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
$taskFinderModel = new TaskFinderModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -223,7 +223,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
$userModel = new UserModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -242,7 +242,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
$userModel = new UserModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -262,7 +262,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$userModel = new UserModel($this->container);
|
||||
$projectRoleModel = new ProjectRoleModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -286,7 +286,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container);
|
||||
$columnRestrictionModel = new ColumnRestrictionModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -313,7 +313,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
$userModel = new UserModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -337,7 +337,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
$userModel = new UserModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -363,7 +363,7 @@ class ProjectRoleHelperTest extends Base
|
||||
$projectRoleModel = new ProjectRoleModel($this->container);
|
||||
$columnMoveRestrictionModel = new ColumnMoveRestrictionModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
|
||||
@@ -57,7 +57,7 @@ class UserHelperTest extends Base
|
||||
{
|
||||
$helper = new UserHelper($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_ADMIN,
|
||||
);
|
||||
@@ -71,7 +71,7 @@ class UserHelperTest extends Base
|
||||
{
|
||||
$helper = new UserHelper($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_MANAGER,
|
||||
);
|
||||
@@ -85,7 +85,7 @@ class UserHelperTest extends Base
|
||||
{
|
||||
$helper = new UserHelper($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -109,7 +109,7 @@ class UserHelperTest extends Base
|
||||
$helper = new UserHelper($this->container);
|
||||
$project = new ProjectModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_ADMIN,
|
||||
);
|
||||
@@ -125,7 +125,7 @@ class UserHelperTest extends Base
|
||||
$helper = new UserHelper($this->container);
|
||||
$project = new ProjectModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_MANAGER,
|
||||
);
|
||||
@@ -141,7 +141,7 @@ class UserHelperTest extends Base
|
||||
$helper = new UserHelper($this->container);
|
||||
$project = new ProjectModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -159,7 +159,7 @@ class UserHelperTest extends Base
|
||||
$project = new ProjectModel($this->container);
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_MANAGER,
|
||||
);
|
||||
@@ -187,7 +187,7 @@ class UserHelperTest extends Base
|
||||
$project = new ProjectModel($this->container);
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -215,7 +215,7 @@ class UserHelperTest extends Base
|
||||
$project = new ProjectModel($this->container);
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -243,7 +243,7 @@ class UserHelperTest extends Base
|
||||
$project = new ProjectModel($this->container);
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
@@ -272,7 +272,7 @@ class UserHelperTest extends Base
|
||||
$projectUserRole = new ProjectUserRoleModel($this->container);
|
||||
$projectRole = new ProjectRoleModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 2,
|
||||
'role' => Role::APP_USER,
|
||||
);
|
||||
|
||||
@@ -70,7 +70,7 @@ class UserMentionJobTest extends Base
|
||||
|
||||
public function testGetMentionedUsersWithNotficationEnabledAndUserLoggedIn()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 3);
|
||||
$_SESSION['user'] = array('id' => 3);
|
||||
$userModel = new UserModel($this->container);
|
||||
$userMentionJob = new UserMentionJob($this->container);
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ class LanguageTest extends Base
|
||||
$languageModel = new LanguageModel($this->container);
|
||||
$this->assertEquals('en', $languageModel->getJsLanguageCode());
|
||||
|
||||
$this->container['sessionStorage']->user = array('language' => 'fr_FR');
|
||||
$_SESSION['user'] = array('language' => 'fr_FR');
|
||||
$this->assertEquals('fr', $languageModel->getJsLanguageCode());
|
||||
|
||||
$this->container['sessionStorage']->user = array('language' => 'xx_XX');
|
||||
$_SESSION['user'] = array('language' => 'xx_XX');
|
||||
$this->assertEquals('en', $languageModel->getJsLanguageCode());
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ class LanguageTest extends Base
|
||||
$languageModel = new LanguageModel($this->container);
|
||||
$this->assertEquals('en_US', $languageModel->getCurrentLanguage());
|
||||
|
||||
$this->container['sessionStorage']->user = array('language' => 'fr_FR');
|
||||
$_SESSION['user'] = array('language' => 'fr_FR');
|
||||
$this->assertEquals('fr_FR', $languageModel->getCurrentLanguage());
|
||||
|
||||
$this->container['sessionStorage']->user = array('language' => 'xx_XX');
|
||||
$_SESSION['user'] = array('language' => 'xx_XX');
|
||||
$this->assertEquals('xx_XX', $languageModel->getCurrentLanguage());
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class ProjectFileTest extends Base
|
||||
|
||||
public function testCreationWithSessionOpen()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$fileModel = new ProjectFileModel($this->container);
|
||||
|
||||
@@ -71,7 +71,7 @@ class SubtaskStatusModelTest extends Base
|
||||
$this->assertEquals(1, $subtask['task_id']);
|
||||
|
||||
// Set the current logged user
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$this->assertEquals(SubtaskModel::STATUS_INPROGRESS, $subtaskStatusModel->toggleStatus(1));
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class SubtaskTimeTrackingModelTest extends Base
|
||||
$subtaskTimeTrackingModel = new SubtaskTimeTrackingModel($this->container);
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
|
||||
|
||||
@@ -159,7 +159,7 @@ class TaskCreationModelTest extends Base
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
$taskFinderModel = new TaskFinderModel($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$this->assertEquals(1, $projectModel->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
|
||||
|
||||
@@ -28,7 +28,7 @@ class TaskDuplicationModelTest extends Base
|
||||
$this->assertEquals(1, $task['project_id']);
|
||||
$this->assertEquals(0, $task['creator_id']);
|
||||
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
// We duplicate our task
|
||||
$this->assertEquals(2, $taskDuplicationModel->duplicate(1));
|
||||
|
||||
@@ -33,7 +33,7 @@ class TaskExternalLinkTest extends Base
|
||||
|
||||
public function testCreateWithUserSession()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
@@ -92,7 +92,7 @@ class TaskExternalLinkTest extends Base
|
||||
|
||||
public function testGetAll()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
$this->container['externalLinkManager'] = new ExternalLinkManager($this->container);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
|
||||
@@ -58,7 +58,7 @@ class TaskFileModelTest extends Base
|
||||
|
||||
public function testCreationWithSessionOpen()
|
||||
{
|
||||
$this->container['sessionStorage']->user = array('id' => 1);
|
||||
$_SESSION['user'] = array('id' => 1);
|
||||
|
||||
$projectModel = new ProjectModel($this->container);
|
||||
$fileModel = new TaskFileModel($this->container);
|
||||
|
||||
@@ -23,10 +23,10 @@ class TimezoneTest extends Base
|
||||
$timezoneModel = new TimezoneModel($this->container);
|
||||
$this->assertEquals('UTC', $timezoneModel->getCurrentTimezone());
|
||||
|
||||
$this->container['sessionStorage']->user = array('timezone' => 'Europe/Paris');
|
||||
$_SESSION['user'] = array('timezone' => 'Europe/Paris');
|
||||
$this->assertEquals('Europe/Paris', $timezoneModel->getCurrentTimezone());
|
||||
|
||||
$this->container['sessionStorage']->user = array('timezone' => 'Something');
|
||||
$_SESSION['user'] = array('timezone' => 'Something');
|
||||
$this->assertEquals('Something', $timezoneModel->getCurrentTimezone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class PasswordResetValidatorTest extends Base
|
||||
|
||||
public function testValidateCreation()
|
||||
{
|
||||
$this->container['sessionStorage']->captcha = 'test';
|
||||
$_SESSION['captcha'] = 'test';
|
||||
|
||||
$passwordResetValidator = new PasswordResetValidator($this->container);
|
||||
list($valid,) = $passwordResetValidator->validateCreation(array('username' => 'foobar', 'captcha' => 'test'));
|
||||
@@ -38,7 +38,7 @@ class PasswordResetValidatorTest extends Base
|
||||
|
||||
public function testValidateCreationWithNoUsername()
|
||||
{
|
||||
$this->container['sessionStorage']->captcha = 'test';
|
||||
$_SESSION['captcha'] = 'test';
|
||||
|
||||
$passwordResetValidator = new PasswordResetValidator($this->container);
|
||||
list($valid,) = $passwordResetValidator->validateCreation(array('captcha' => 'test'));
|
||||
@@ -47,7 +47,7 @@ class PasswordResetValidatorTest extends Base
|
||||
|
||||
public function testValidateCreationWithWrongCaptcha()
|
||||
{
|
||||
$this->container['sessionStorage']->captcha = 'test123';
|
||||
$_SESSION['captcha'] = 'test123';
|
||||
|
||||
$passwordResetValidator = new PasswordResetValidator($this->container);
|
||||
list($valid,) = $passwordResetValidator->validateCreation(array('username' => 'foobar', 'captcha' => 'test'));
|
||||
|
||||
@@ -11,7 +11,7 @@ class UserValidatorTest extends Base
|
||||
{
|
||||
$userValidator = new UserValidator($this->container);
|
||||
|
||||
$this->container['sessionStorage']->user = array(
|
||||
$_SESSION['user'] = array(
|
||||
'id' => 1,
|
||||
'role' => Role::APP_ADMIN,
|
||||
'username' => 'admin',
|
||||
|
||||
Reference in New Issue
Block a user