diff options
author | Frédéric Guillot <fred@kanboard.net> | 2017-12-06 16:19:11 -0800 |
---|---|---|
committer | Frédéric Guillot <fguillot@apple.com> | 2017-12-12 15:04:28 -0800 |
commit | ccd177ada6823c27a6408427f19c238fd701c39e (patch) | |
tree | 9846c792bd4c4f9318768f00db0e8f00cc25954b /tests | |
parent | 421531bd4f0af6a26e0b7971e23d5af1d5cf7d05 (diff) |
Store PHP sessions in the database
Diffstat (limited to 'tests')
26 files changed, 129 insertions, 195 deletions
diff --git a/tests/units/Action/CommentCreationMoveTaskColumnTest.php b/tests/units/Action/CommentCreationMoveTaskColumnTest.php index b3d21287..202c6515 100644 --- a/tests/units/Action/CommentCreationMoveTaskColumnTest.php +++ b/tests/units/Action/CommentCreationMoveTaskColumnTest.php @@ -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); diff --git a/tests/units/Action/TaskAssignCurrentUserColumnTest.php b/tests/units/Action/TaskAssignCurrentUserColumnTest.php index 3b64d718..9ebc9cce 100644 --- a/tests/units/Action/TaskAssignCurrentUserColumnTest.php +++ b/tests/units/Action/TaskAssignCurrentUserColumnTest.php @@ -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); diff --git a/tests/units/Action/TaskAssignCurrentUserTest.php b/tests/units/Action/TaskAssignCurrentUserTest.php index 5569a191..a06b204b 100644 --- a/tests/units/Action/TaskAssignCurrentUserTest.php +++ b/tests/units/Action/TaskAssignCurrentUserTest.php @@ -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); diff --git a/tests/units/Auth/ApiAccessTokenAuthTest.php b/tests/units/Auth/ApiAccessTokenAuthTest.php index 22852805..337d6039 100644 --- a/tests/units/Auth/ApiAccessTokenAuthTest.php +++ b/tests/units/Auth/ApiAccessTokenAuthTest.php @@ -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); diff --git a/tests/units/Auth/DatabaseAuthTest.php b/tests/units/Auth/DatabaseAuthTest.php index 97c75bd2..50ae3c7e 100644 --- a/tests/units/Auth/DatabaseAuthTest.php +++ b/tests/units/Auth/DatabaseAuthTest.php @@ -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()); } } diff --git a/tests/units/Auth/ReverseProxyAuthTest.php b/tests/units/Auth/ReverseProxyAuthTest.php index cdbc247d..10d0841e 100644 --- a/tests/units/Auth/ReverseProxyAuthTest.php +++ b/tests/units/Auth/ReverseProxyAuthTest.php @@ -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' ); diff --git a/tests/units/Base.php b/tests/units/Base.php index f7c99425..cb6a2e20 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -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) { diff --git a/tests/units/Core/Action/ActionManagerTest.php b/tests/units/Core/Action/ActionManagerTest.php index 4878c0c9..cf6a88d4 100644 --- a/tests/units/Core/Action/ActionManagerTest.php +++ b/tests/units/Core/Action/ActionManagerTest.php @@ -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); diff --git a/tests/units/Core/Security/AuthenticationManagerTest.php b/tests/units/Core/Security/AuthenticationManagerTest.php index c2369626..a5a23c7e 100644 --- a/tests/units/Core/Security/AuthenticationManagerTest.php +++ b/tests/units/Core/Security/AuthenticationManagerTest.php @@ -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()); diff --git a/tests/units/Core/Session/SessionStorageTest.php b/tests/units/Core/Session/SessionStorageTest.php deleted file mode 100644 index dd0040d5..00000000 --- a/tests/units/Core/Session/SessionStorageTest.php +++ /dev/null @@ -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); - } -} diff --git a/tests/units/Core/User/UserProfileTest.php b/tests/units/Core/User/UserProfileTest.php index 6dc627b7..684db06e 100644 --- a/tests/units/Core/User/UserProfileTest.php +++ b/tests/units/Core/User/UserProfileTest.php @@ -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']); } } diff --git a/tests/units/Core/User/UserSessionTest.php b/tests/units/Core/User/UserSessionTest.php index 2a118079..5e7bab43 100644 --- a/tests/units/Core/User/UserSessionTest.php +++ b/tests/units/Core/User/UserSessionTest.php @@ -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); - - $session = $this->container['sessionStorage']->getAll(); + $userSession->initialize($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->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); - - $this->assertFalse($us->isAdmin()); + $userSession = new UserSession($this->container); + $this->assertFalse($userSession->isAdmin()); - $this->container['sessionStorage']->user = array('role' => Role::APP_ADMIN); - $this->assertTrue($us->isAdmin()); + $_SESSION['user'] = array('role' => Role::APP_ADMIN); + $this->assertTrue($userSession->isAdmin()); - $this->container['sessionStorage']->user = array('role' => Role::APP_USER); - $this->assertFalse($us->isAdmin()); + $_SESSION['user'] = array('role' => Role::APP_USER); + $this->assertFalse($userSession->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()); } } diff --git a/tests/units/Helper/ProjectRoleHelperTest.php b/tests/units/Helper/ProjectRoleHelperTest.php index d2335dfa..f6b5afff 100644 --- a/tests/units/Helper/ProjectRoleHelperTest.php +++ b/tests/units/Helper/ProjectRoleHelperTest.php @@ -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, ); diff --git a/tests/units/Helper/UserHelperTest.php b/tests/units/Helper/UserHelperTest.php index b66acdba..efd7410b 100644 --- a/tests/units/Helper/UserHelperTest.php +++ b/tests/units/Helper/UserHelperTest.php @@ -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, ); diff --git a/tests/units/Job/UserMentionJobTest.php b/tests/units/Job/UserMentionJobTest.php index 04ffa0d3..b2bfe41c 100644 --- a/tests/units/Job/UserMentionJobTest.php +++ b/tests/units/Job/UserMentionJobTest.php @@ -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); diff --git a/tests/units/Model/LanguageTest.php b/tests/units/Model/LanguageTest.php index 4330c3c8..88f6df6e 100644 --- a/tests/units/Model/LanguageTest.php +++ b/tests/units/Model/LanguageTest.php @@ -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()); } diff --git a/tests/units/Model/ProjectFileTest.php b/tests/units/Model/ProjectFileTest.php index 116dd3d2..dfecb5ec 100644 --- a/tests/units/Model/ProjectFileTest.php +++ b/tests/units/Model/ProjectFileTest.php @@ -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); diff --git a/tests/units/Model/SubtaskStatusModelTest.php b/tests/units/Model/SubtaskStatusModelTest.php index af4c3955..6047001b 100644 --- a/tests/units/Model/SubtaskStatusModelTest.php +++ b/tests/units/Model/SubtaskStatusModelTest.php @@ -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)); diff --git a/tests/units/Model/SubtaskTimeTrackingModelTest.php b/tests/units/Model/SubtaskTimeTrackingModelTest.php index 120cfc2c..071785c3 100644 --- a/tests/units/Model/SubtaskTimeTrackingModelTest.php +++ b/tests/units/Model/SubtaskTimeTrackingModelTest.php @@ -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))); diff --git a/tests/units/Model/TaskCreationModelTest.php b/tests/units/Model/TaskCreationModelTest.php index 7723bece..4b04ac3b 100644 --- a/tests/units/Model/TaskCreationModelTest.php +++ b/tests/units/Model/TaskCreationModelTest.php @@ -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'))); diff --git a/tests/units/Model/TaskDuplicationModelTest.php b/tests/units/Model/TaskDuplicationModelTest.php index e4121ff9..1295cd37 100644 --- a/tests/units/Model/TaskDuplicationModelTest.php +++ b/tests/units/Model/TaskDuplicationModelTest.php @@ -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)); diff --git a/tests/units/Model/TaskExternalLinkTest.php b/tests/units/Model/TaskExternalLinkTest.php index 7b61cb90..d734f70e 100644 --- a/tests/units/Model/TaskExternalLinkTest.php +++ b/tests/units/Model/TaskExternalLinkTest.php @@ -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); diff --git a/tests/units/Model/TaskFileModelTest.php b/tests/units/Model/TaskFileModelTest.php index de12553f..3c30cc0b 100644 --- a/tests/units/Model/TaskFileModelTest.php +++ b/tests/units/Model/TaskFileModelTest.php @@ -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); diff --git a/tests/units/Model/TimezoneTest.php b/tests/units/Model/TimezoneTest.php index 8e7103d8..a839f2cc 100644 --- a/tests/units/Model/TimezoneTest.php +++ b/tests/units/Model/TimezoneTest.php @@ -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()); } } diff --git a/tests/units/Validator/PasswordResetValidatorTest.php b/tests/units/Validator/PasswordResetValidatorTest.php index eed77e42..a2647d2d 100644 --- a/tests/units/Validator/PasswordResetValidatorTest.php +++ b/tests/units/Validator/PasswordResetValidatorTest.php @@ -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')); diff --git a/tests/units/Validator/UserValidatorTest.php b/tests/units/Validator/UserValidatorTest.php index 64c76175..ae9c94da 100644 --- a/tests/units/Validator/UserValidatorTest.php +++ b/tests/units/Validator/UserValidatorTest.php @@ -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', |