summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-10-12 15:32:35 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-10-12 15:32:35 -0400
commit4061927d215c846ff8eb196301bf61532018042b (patch)
tree0e14a0e458ee8739754f75f8c158cc42a9b593a4 /tests
parentb7060b33ef317eeac576c504b1fb840d4471e411 (diff)
Move some Task model methods to the TaskFinder class
Diffstat (limited to 'tests')
-rw-r--r--tests/units/ActionTaskAssignColorCategoryTest.php6
-rw-r--r--tests/units/ActionTaskAssignColorUserTest.php6
-rw-r--r--tests/units/ActionTaskAssignCurrentUserTest.php4
-rw-r--r--tests/units/ActionTaskAssignSpecificUserTest.php4
-rw-r--r--tests/units/ActionTaskCloseTest.php4
-rw-r--r--tests/units/ActionTaskDuplicateAnotherProjectTest.php8
-rw-r--r--tests/units/ActionTaskMoveAnotherProjectTest.php6
-rw-r--r--tests/units/ActionTest.php13
-rw-r--r--tests/units/CategoryTest.php9
-rw-r--r--tests/units/TaskFinderTest.php32
-rw-r--r--tests/units/TaskPermissionTest.php18
-rw-r--r--tests/units/TaskTest.php161
-rw-r--r--tests/units/TimeTrackingTest.php4
-rw-r--r--tests/units/UserTest.php6
14 files changed, 167 insertions, 114 deletions
diff --git a/tests/units/ActionTaskAssignColorCategoryTest.php b/tests/units/ActionTaskAssignColorCategoryTest.php
index 5a8c0458..b7d99dae 100644
--- a/tests/units/ActionTaskAssignColorCategoryTest.php
+++ b/tests/units/ActionTaskAssignColorCategoryTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
use Model\Category;
@@ -30,6 +31,7 @@ class ActionTaskAssignColorCategory extends Base
// We create a task in the first column
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
@@ -51,7 +53,7 @@ class ActionTaskAssignColorCategory extends Base
$this->assertFalse($action->execute($event));
// Our task should be assigned to the ategory_id=1 and have the green color
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['category_id']);
$this->assertEquals('green', $task['color_id']);
@@ -69,7 +71,7 @@ class ActionTaskAssignColorCategory extends Base
$this->assertTrue($action->execute($event));
// Our task should have the blue color
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals('blue', $task['color_id']);
}
diff --git a/tests/units/ActionTaskAssignColorUserTest.php b/tests/units/ActionTaskAssignColorUserTest.php
index 8f6a891e..61600fdc 100644
--- a/tests/units/ActionTaskAssignColorUserTest.php
+++ b/tests/units/ActionTaskAssignColorUserTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
class ActionTaskAssignColorUser extends Base
@@ -29,6 +30,7 @@ class ActionTaskAssignColorUser extends Base
// We create a task in the first column
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
@@ -44,7 +46,7 @@ class ActionTaskAssignColorUser extends Base
$this->assertFalse($action->execute($event));
// Our task should be assigned to nobody and have the green color
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals('green', $task['color_id']);
@@ -60,7 +62,7 @@ class ActionTaskAssignColorUser extends Base
$this->assertTrue($action->execute($event));
// Our task should be assigned to nobody and have the blue color
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals('blue', $task['color_id']);
diff --git a/tests/units/ActionTaskAssignCurrentUserTest.php b/tests/units/ActionTaskAssignCurrentUserTest.php
index cfed7be5..edc2577c 100644
--- a/tests/units/ActionTaskAssignCurrentUserTest.php
+++ b/tests/units/ActionTaskAssignCurrentUserTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
use Model\Acl;
@@ -47,6 +48,7 @@ class ActionTaskAssignCurrentUser extends Base
// We create a task in the first column
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$a = new Acl($this->registry);
@@ -65,7 +67,7 @@ class ActionTaskAssignCurrentUser extends Base
$this->assertTrue($action->execute($event));
// Our task should be assigned to the user 5 (from the session)
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['id']);
$this->assertEquals(5, $task['owner_id']);
diff --git a/tests/units/ActionTaskAssignSpecificUserTest.php b/tests/units/ActionTaskAssignSpecificUserTest.php
index de8daf11..8795d5fb 100644
--- a/tests/units/ActionTaskAssignSpecificUserTest.php
+++ b/tests/units/ActionTaskAssignSpecificUserTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
class ActionTaskAssignSpecificUser extends Base
@@ -44,6 +45,7 @@ class ActionTaskAssignSpecificUser extends Base
// We create a task in the first column
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
@@ -59,7 +61,7 @@ class ActionTaskAssignSpecificUser extends Base
$this->assertTrue($action->execute($event));
// Our task should be assigned to the user 1
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
}
diff --git a/tests/units/ActionTaskCloseTest.php b/tests/units/ActionTaskCloseTest.php
index 73ff57f3..6c8e4cf1 100644
--- a/tests/units/ActionTaskCloseTest.php
+++ b/tests/units/ActionTaskCloseTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
use Model\GithubWebhook;
@@ -82,6 +83,7 @@ class ActionTaskCloseTest extends Base
// We create a task in the first column
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
@@ -97,7 +99,7 @@ class ActionTaskCloseTest extends Base
$this->assertTrue($action->execute($event));
// Our task should be closed
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['is_active']);
}
diff --git a/tests/units/ActionTaskDuplicateAnotherProjectTest.php b/tests/units/ActionTaskDuplicateAnotherProjectTest.php
index 75aeedf8..6fb3c8d8 100644
--- a/tests/units/ActionTaskDuplicateAnotherProjectTest.php
+++ b/tests/units/ActionTaskDuplicateAnotherProjectTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
class ActionTaskDuplicateAnotherProject extends Base
@@ -42,6 +43,7 @@ class ActionTaskDuplicateAnotherProject extends Base
// We create a task in the first column
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
@@ -60,7 +62,7 @@ class ActionTaskDuplicateAnotherProject extends Base
$this->assertFalse($action->execute($event));
// Our task should be assigned to the project 1
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['project_id']);
@@ -77,12 +79,12 @@ class ActionTaskDuplicateAnotherProject extends Base
$this->assertTrue($action->execute($event));
// Our task should be assigned to the project 1
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['project_id']);
// We should have another task assigned to the project 2
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
}
diff --git a/tests/units/ActionTaskMoveAnotherProjectTest.php b/tests/units/ActionTaskMoveAnotherProjectTest.php
index b395a279..903cc392 100644
--- a/tests/units/ActionTaskMoveAnotherProjectTest.php
+++ b/tests/units/ActionTaskMoveAnotherProjectTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
class ActionTaskMoveAnotherProject extends Base
@@ -42,6 +43,7 @@ class ActionTaskMoveAnotherProject extends Base
// We create a task in the first column
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
@@ -60,7 +62,7 @@ class ActionTaskMoveAnotherProject extends Base
$this->assertFalse($action->execute($event));
// Our task should be assigned to the project 1
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['project_id']);
@@ -77,7 +79,7 @@ class ActionTaskMoveAnotherProject extends Base
$this->assertTrue($action->execute($event));
// Our task should be assigned to the project 2
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
}
diff --git a/tests/units/ActionTest.php b/tests/units/ActionTest.php
index f155d0c0..aa923445 100644
--- a/tests/units/ActionTest.php
+++ b/tests/units/ActionTest.php
@@ -6,6 +6,7 @@ use Model\Action;
use Model\Project;
use Model\Board;
use Model\Task;
+use Model\TaskFinder;
use Model\Category;
class ActionTest extends Base
@@ -49,6 +50,7 @@ class ActionTest extends Base
public function testEventMoveColumn()
{
$task = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$board = new Board($this->registry);
$project = new Project($this->registry);
$action = new Action($this->registry);
@@ -79,7 +81,7 @@ class ActionTest extends Base
$action->attachEvents();
// Our task should be open
- $t1 = $task->getById(1);
+ $t1 = $tf->getById(1);
$this->assertEquals(1, $t1['is_active']);
$this->assertEquals(1, $t1['column_id']);
@@ -90,7 +92,7 @@ class ActionTest extends Base
$this->assertFalse($this->registry->shared('event')->isEventTriggered(Task::EVENT_UPDATE));
// Our task should be closed
- $t1 = $task->getById(1);
+ $t1 = $tf->getById(1);
$this->assertEquals(4, $t1['column_id']);
$this->assertEquals(0, $t1['is_active']);
}
@@ -98,6 +100,7 @@ class ActionTest extends Base
public function testExecuteMultipleActions()
{
$task = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$board = new Board($this->registry);
$project = new Project($this->registry);
$action = new Action($this->registry);
@@ -143,7 +146,7 @@ class ActionTest extends Base
$this->assertTrue($this->registry->shared('event')->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\TaskClose'));
// Our task should be open, linked to the first project and in the first column
- $t1 = $task->getById(1);
+ $t1 = $tf->getById(1);
$this->assertEquals(1, $t1['is_active']);
$this->assertEquals(1, $t1['column_id']);
$this->assertEquals(1, $t1['project_id']);
@@ -155,12 +158,12 @@ class ActionTest extends Base
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
// Our task should be closed
- $t1 = $task->getById(1);
+ $t1 = $tf->getById(1);
$this->assertEquals(4, $t1['column_id']);
$this->assertEquals(0, $t1['is_active']);
// Our task should be duplicated to the 2nd project
- $t2 = $task->getById(2);
+ $t2 = $tf->getById(2);
$this->assertNotEmpty($t2);
$this->assertNotEquals(4, $t2['column_id']);
$this->assertEquals(1, $t2['is_active']);
diff --git a/tests/units/CategoryTest.php b/tests/units/CategoryTest.php
index 201fa589..ef061419 100644
--- a/tests/units/CategoryTest.php
+++ b/tests/units/CategoryTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
use Model\Category;
use Model\User;
@@ -12,6 +13,7 @@ class CategoryTest extends Base
public function testCreation()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
@@ -20,7 +22,7 @@ class CategoryTest extends Base
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertTrue(is_array($task));
$this->assertEquals(2, $task['category_id']);
@@ -34,6 +36,7 @@ class CategoryTest extends Base
public function testRemove()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
@@ -42,7 +45,7 @@ class CategoryTest extends Base
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertTrue(is_array($task));
$this->assertEquals(2, $task['category_id']);
@@ -50,7 +53,7 @@ class CategoryTest extends Base
$this->assertTrue($c->remove(2));
// Make sure tasks assigned with that category are reseted
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertTrue(is_array($task));
$this->assertEquals(0, $task['category_id']);
}
diff --git a/tests/units/TaskFinderTest.php b/tests/units/TaskFinderTest.php
new file mode 100644
index 00000000..5a90f3af
--- /dev/null
+++ b/tests/units/TaskFinderTest.php
@@ -0,0 +1,32 @@
+<?php
+
+require_once __DIR__.'/Base.php';
+
+use Model\Task;
+use Model\TaskFinder;
+use Model\Project;
+use Model\ProjectPermission;
+use Model\Category;
+use Model\User;
+
+class TaskFinderTest extends Base
+{
+ public function testGetOverdueTasks()
+ {
+ $t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
+ $p = new Project($this->registry);
+
+ $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
+ $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
+ $this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
+ $this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
+ $this->assertEquals(4, $t->create(array('title' => 'Task #3', 'project_id' => 1)));
+
+ $tasks = $tf->getOverdueTasks();
+ $this->assertNotEmpty($tasks);
+ $this->assertTrue(is_array($tasks));
+ $this->assertEquals(1, count($tasks));
+ $this->assertEquals('Task #1', $tasks[0]['title']);
+ }
+}
diff --git a/tests/units/TaskPermissionTest.php b/tests/units/TaskPermissionTest.php
index 66036990..5a94a274 100644
--- a/tests/units/TaskPermissionTest.php
+++ b/tests/units/TaskPermissionTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\TaskPermission;
use Model\Project;
use Model\Category;
@@ -13,6 +14,7 @@ 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);
@@ -30,7 +32,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(1);
+ $task = $tf->getbyId(1);
$this->assertNotEmpty($task);
$this->assertTrue($tp->canRemoveTask($task));
@@ -39,7 +41,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(1);
+ $task = $tf->getbyId(1);
$this->assertNotEmpty($task);
$this->assertFalse($tp->canRemoveTask($task));
@@ -48,7 +50,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(2);
+ $task = $tf->getbyId(2);
$this->assertNotEmpty($task);
$this->assertTrue($tp->canRemoveTask($task));
@@ -57,7 +59,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(2);
+ $task = $tf->getbyId(2);
$this->assertNotEmpty($task);
$this->assertTrue($tp->canRemoveTask($task));
@@ -66,7 +68,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(3);
+ $task = $tf->getbyId(3);
$this->assertNotEmpty($task);
$this->assertTrue($tp->canRemoveTask($task));
@@ -75,7 +77,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(3);
+ $task = $tf->getbyId(3);
$this->assertNotEmpty($task);
$this->assertFalse($tp->canRemoveTask($task));
@@ -84,7 +86,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(4);
+ $task = $tf->getbyId(4);
$this->assertNotEmpty($task);
$this->assertTrue($tp->canRemoveTask($task));
@@ -93,7 +95,7 @@ class TaskPermissionTest extends Base
$this->assertNotEmpty($user);
$u->updateSession($user);
- $task = $t->getbyId(4);
+ $task = $tf->getbyId(4);
$this->assertNotEmpty($task);
$this->assertFalse($tp->canRemoveTask($task));
}
diff --git a/tests/units/TaskTest.php b/tests/units/TaskTest.php
index 4d121fcd..e82faf19 100644
--- a/tests/units/TaskTest.php
+++ b/tests/units/TaskTest.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/Base.php';
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
use Model\ProjectPermission;
use Model\Category;
@@ -13,6 +14,7 @@ class TaskTest extends Base
public function testPrepareCreation()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -91,6 +93,7 @@ class TaskTest extends Base
public function testPrepareModification()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -110,12 +113,13 @@ class TaskTest extends Base
public function testCreation()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
@@ -126,7 +130,7 @@ class TaskTest extends Base
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1)));
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
@@ -134,19 +138,20 @@ class TaskTest extends Base
$this->assertEquals(time(), $task['date_modification']);
$this->assertEquals(0, $task['date_due']);
- $tasks = $t->getAll(1, 1);
+ $tasks = $tf->getAll(1, 1);
$this->assertNotEmpty($tasks);
$this->assertTrue(is_array($tasks));
$this->assertEquals(1, $tasks[0]['id']);
$this->assertEquals(2, $tasks[1]['id']);
- $tasks = $t->getAll(1, 0);
+ $tasks = $tf->getAll(1, 0);
$this->assertEmpty($tasks);
}
public function testRemove()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
@@ -156,27 +161,10 @@ class TaskTest extends Base
$this->assertFalse($t->remove(1234));
}
- public function testGetOverdueTasks()
- {
- $t = new Task($this->registry);
- $p = new Project($this->registry);
-
- $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
- $this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
- $this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
- $this->assertEquals(4, $t->create(array('title' => 'Task #3', 'project_id' => 1)));
-
- $tasks = $t->getOverdueTasks();
- $this->assertNotEmpty($tasks);
- $this->assertTrue(is_array($tasks));
- $this->assertEquals(1, count($tasks));
- $this->assertEquals('Task #1', $tasks[0]['title']);
- }
-
public function testMoveTaskWithColumnThatNotChange()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -194,42 +182,42 @@ class TaskTest extends Base
$this->assertTrue($t->movePosition(1, 3, 3, 2));
// Check tasks position
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $task = $t->getById(3);
+ $task = $tf->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(3, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $task = $t->getById(4);
+ $task = $tf->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $task = $t->getById(5);
+ $task = $tf->getById(5);
$this->assertEquals(5, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $task = $t->getById(6);
+ $task = $tf->getById(6);
$this->assertEquals(6, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(3, $task['position']);
- $task = $t->getById(7);
+ $task = $tf->getById(7);
$this->assertEquals(7, $task['id']);
$this->assertEquals(3, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $task = $t->getById(8);
+ $task = $tf->getById(8);
$this->assertEquals(8, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(3, $task['position']);
@@ -238,6 +226,7 @@ class TaskTest extends Base
public function testMoveTaskWithBadPreviousPosition()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -251,17 +240,17 @@ class TaskTest extends Base
$this->assertTrue($t->movePosition(1, 1, 2, 3));
// Check tasks position
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $task = $t->getById(3);
+ $task = $tf->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(3, $task['position']);
@@ -270,6 +259,7 @@ class TaskTest extends Base
public function testMoveTaskTop()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -282,22 +272,22 @@ class TaskTest extends Base
$this->assertTrue($t->movePosition(1, 4, 1, 1));
// Check tasks position
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(3, $task['position']);
- $task = $t->getById(3);
+ $task = $tf->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(4, $task['position']);
- $task = $t->getById(4);
+ $task = $tf->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
@@ -306,6 +296,7 @@ class TaskTest extends Base
public function testMoveTaskBottom()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -318,22 +309,22 @@ class TaskTest extends Base
$this->assertTrue($t->movePosition(1, 1, 1, 4));
// Check tasks position
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(4, $task['position']);
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $task = $t->getById(3);
+ $task = $tf->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $task = $t->getById(4);
+ $task = $tf->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(3, $task['position']);
@@ -342,6 +333,7 @@ class TaskTest extends Base
public function testMovePosition()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -361,7 +353,7 @@ class TaskTest extends Base
$this->assertEquals($counter, $t->create($task));
- $task = $t->getById($counter);
+ $task = $tf->getById($counter);
$this->assertNotFalse($task);
$this->assertNotEmpty($task);
$this->assertEquals($i, $task['position']);
@@ -372,68 +364,68 @@ class TaskTest extends Base
$this->assertTrue($t->movePosition(1, 4, 2, 3));
// We check the new position of the task
- $task = $t->getById(4);
+ $task = $tf->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(3, $task['position']);
// The tasks before have the correct position
- $task = $t->getById(3);
+ $task = $tf->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(3, $task['position']);
- $task = $t->getById(7);
+ $task = $tf->getById(7);
$this->assertEquals(7, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(2, $task['position']);
// The tasks after have the correct position
- $task = $t->getById(5);
+ $task = $tf->getById(5);
$this->assertEquals(5, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(4, $task['position']);
- $task = $t->getById(8);
+ $task = $tf->getById(8);
$this->assertEquals(8, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(4, $task['position']);
// The number of tasks per column
- $this->assertEquals($task_per_column - 1, $t->countByColumnId(1, 1));
- $this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
- $this->assertEquals($task_per_column, $t->countByColumnId(1, 3));
- $this->assertEquals($task_per_column, $t->countByColumnId(1, 4));
+ $this->assertEquals($task_per_column - 1, $tf->countByColumnId(1, 1));
+ $this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
+ $this->assertEquals($task_per_column, $tf->countByColumnId(1, 3));
+ $this->assertEquals($task_per_column, $tf->countByColumnId(1, 4));
// We move task id #1, column 1, position 1 to the column 4, position 6 (last position)
$this->assertTrue($t->movePosition(1, 1, 4, $task_per_column + 1));
// We check the new position of the task
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(4, $task['column_id']);
$this->assertEquals($task_per_column + 1, $task['position']);
// The tasks before have the correct position
- $task = $t->getById(20);
+ $task = $tf->getById(20);
$this->assertEquals(20, $task['id']);
$this->assertEquals(4, $task['column_id']);
$this->assertEquals($task_per_column, $task['position']);
// The tasks after have the correct position
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
// The number of tasks per column
- $this->assertEquals($task_per_column - 2, $t->countByColumnId(1, 1));
- $this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
- $this->assertEquals($task_per_column, $t->countByColumnId(1, 3));
- $this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 4));
+ $this->assertEquals($task_per_column - 2, $tf->countByColumnId(1, 1));
+ $this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
+ $this->assertEquals($task_per_column, $tf->countByColumnId(1, 3));
+ $this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 4));
// Our previous moved task should stay at the same place
- $task = $t->getById(4);
+ $task = $tf->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(3, $task['position']);
@@ -448,28 +440,28 @@ class TaskTest extends Base
// Test position greater than the last position
$this->assertTrue($t->movePosition(1, 11, 1, 22));
- $task = $t->getById(11);
+ $task = $tf->getById(11);
$this->assertEquals(11, $task['id']);
$this->assertEquals(1, $task['column_id']);
- $this->assertEquals($t->countByColumnId(1, 1), $task['position']);
+ $this->assertEquals($tf->countByColumnId(1, 1), $task['position']);
- $task = $t->getById(5);
+ $task = $tf->getById(5);
$this->assertEquals(5, $task['id']);
$this->assertEquals(1, $task['column_id']);
- $this->assertEquals($t->countByColumnId(1, 1) - 1, $task['position']);
+ $this->assertEquals($tf->countByColumnId(1, 1) - 1, $task['position']);
- $task = $t->getById(4);
+ $task = $tf->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(3, $task['position']);
- $this->assertEquals($task_per_column - 1, $t->countByColumnId(1, 1));
- $this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
- $this->assertEquals($task_per_column - 1, $t->countByColumnId(1, 3));
- $this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 4));
+ $this->assertEquals($task_per_column - 1, $tf->countByColumnId(1, 1));
+ $this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
+ $this->assertEquals($task_per_column - 1, $tf->countByColumnId(1, 3));
+ $this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 4));
// Our previous moved task should stay at the same place
- $task = $t->getById(4);
+ $task = $tf->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(3, $task['position']);
@@ -477,25 +469,26 @@ class TaskTest extends Base
// Test moving task to position 1
$this->assertTrue($t->movePosition(1, 14, 1, 1));
- $task = $t->getById(14);
+ $task = $tf->getById(14);
$this->assertEquals(14, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $this->assertEquals($task_per_column, $t->countByColumnId(1, 1));
- $this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
- $this->assertEquals($task_per_column - 2, $t->countByColumnId(1, 3));
- $this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 4));
+ $this->assertEquals($task_per_column, $tf->countByColumnId(1, 1));
+ $this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
+ $this->assertEquals($task_per_column - 2, $tf->countByColumnId(1, 3));
+ $this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 4));
}
public function testDuplicateToTheSameProject()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
@@ -510,7 +503,7 @@ class TaskTest extends Base
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2)));
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['position']);
@@ -519,7 +512,7 @@ class TaskTest extends Base
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(Task::STATUS_OPEN, $task['is_active']);
$this->assertEquals(1, $task['project_id']);
@@ -532,6 +525,7 @@ class TaskTest extends Base
public function testDuplicateToAnotherProject()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
@@ -544,14 +538,14 @@ class TaskTest extends Base
// We create a task
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
- $task = $t->getById(1);
+ $task = $tf->getById(1);
// We duplicate our task to the 2nd project
$this->assertEquals(2, $t->duplicateToAnotherProject(2, $task));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
@@ -564,6 +558,7 @@ class TaskTest extends Base
public function testMoveToAnotherProject()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$user = new User($this->registry);
@@ -581,12 +576,12 @@ class TaskTest extends Base
$this->assertEquals(2, $t->create(array('title' => 'test2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3, 'category_id' => 10, 'position' => 333)));
// We duplicate our task to the 2nd project
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $t->moveToAnotherProject(2, $task));
//$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
@@ -599,10 +594,10 @@ class TaskTest extends Base
$this->assertTrue($pp->allowUser(2, 2));
// The owner should be reseted
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertEquals(2, $t->moveToAnotherProject(2, $task));
- $task = $t->getById(2);
+ $task = $tf->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
}
diff --git a/tests/units/TimeTrackingTest.php b/tests/units/TimeTrackingTest.php
index 50d5cb53..aa772a36 100644
--- a/tests/units/TimeTrackingTest.php
+++ b/tests/units/TimeTrackingTest.php
@@ -4,6 +4,7 @@ require_once __DIR__.'/Base.php';
use Model\SubTask;
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
use Model\TimeTracking;
@@ -12,6 +13,7 @@ class TimeTrackingTest extends Base
public function testCalculateTime()
{
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$s = new SubTask($this->registry);
$ts = new TimeTracking($this->registry);
@@ -20,7 +22,7 @@ class TimeTrackingTest extends Base
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));
$this->assertTrue($t->update(array('id' => 1, 'time_spent' => 3.5)));
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(4.5, $task['time_estimated']);
$this->assertEquals(3.5, $task['time_spent']);
diff --git a/tests/units/UserTest.php b/tests/units/UserTest.php
index 9a304e85..b66a6c27 100644
--- a/tests/units/UserTest.php
+++ b/tests/units/UserTest.php
@@ -4,6 +4,7 @@ require_once __DIR__.'/Base.php';
use Model\User;
use Model\Task;
+use Model\TaskFinder;
use Model\Project;
class UserTest extends Base
@@ -110,13 +111,14 @@ class UserTest extends Base
{
$u = new User($this->registry);
$t = new Task($this->registry);
+ $tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(2, $task['owner_id']);
@@ -126,7 +128,7 @@ class UserTest extends Base
$this->assertFalse($u->remove(55));
// Make sure that assigned tasks are unassigned after removing the user
- $task = $t->getById(1);
+ $task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(0, $task['owner_id']);
}