summaryrefslogtreecommitdiff
path: root/tests/units/TaskPermissionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/TaskPermissionTest.php')
-rw-r--r--tests/units/TaskPermissionTest.php43
1 files changed, 23 insertions, 20 deletions
diff --git a/tests/units/TaskPermissionTest.php b/tests/units/TaskPermissionTest.php
index 5a94a274..0bf68ce3 100644
--- a/tests/units/TaskPermissionTest.php
+++ b/tests/units/TaskPermissionTest.php
@@ -3,34 +3,37 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskCreation;
use Model\TaskFinder;
use Model\TaskPermission;
use Model\Project;
use Model\Category;
use Model\User;
+use Model\UserSession;
class TaskPermissionTest extends Base
{
public function testPrepareCreation()
{
- $t = new Task($this->registry);
- $tf = new TaskFinder($this->registry);
- $tp = new TaskPermission($this->registry);
- $p = new Project($this->registry);
- $u = new User($this->registry);
-
- $this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456')));
- $this->assertTrue($u->create(array('username' => 'toto2', 'password' => '123456')));
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $tp = new TaskPermission($this->container);
+ $p = new Project($this->container);
+ $u = new User($this->container);
+ $us = new UserSession($this->container);
+
+ $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456')));
+ $this->assertNotFalse($u->create(array('username' => 'toto2', 'password' => '123456')));
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'creator_id' => 1)));
- $this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'creator_id' => 2)));
- $this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'creator_id' => 3)));
- $this->assertEquals(4, $t->create(array('title' => 'Task #4', 'project_id' => 1)));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'creator_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'creator_id' => 2)));
+ $this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'creator_id' => 3)));
+ $this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1)));
// User #1 can remove everything
$user = $u->getbyId(1);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(1);
$this->assertNotEmpty($task);
@@ -39,7 +42,7 @@ class TaskPermissionTest extends Base
// User #2 can't remove the task #1
$user = $u->getbyId(2);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(1);
$this->assertNotEmpty($task);
@@ -48,7 +51,7 @@ class TaskPermissionTest extends Base
// User #1 can remove everything
$user = $u->getbyId(1);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(2);
$this->assertNotEmpty($task);
@@ -57,7 +60,7 @@ class TaskPermissionTest extends Base
// User #2 can remove his own task
$user = $u->getbyId(2);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(2);
$this->assertNotEmpty($task);
@@ -66,7 +69,7 @@ class TaskPermissionTest extends Base
// User #1 can remove everything
$user = $u->getbyId(1);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(3);
$this->assertNotEmpty($task);
@@ -75,7 +78,7 @@ class TaskPermissionTest extends Base
// User #2 can't remove the task #3
$user = $u->getbyId(2);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(3);
$this->assertNotEmpty($task);
@@ -84,7 +87,7 @@ class TaskPermissionTest extends Base
// User #1 can remove everything
$user = $u->getbyId(1);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(4);
$this->assertNotEmpty($task);
@@ -93,7 +96,7 @@ class TaskPermissionTest extends Base
// User #2 can't remove the task #4
$user = $u->getbyId(2);
$this->assertNotEmpty($user);
- $u->updateSession($user);
+ $us->refresh($user);
$task = $tf->getbyId(4);
$this->assertNotEmpty($task);