summaryrefslogtreecommitdiff
path: root/tests/units/TaskFinderTest.php
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/units/TaskFinderTest.php
parentb7060b33ef317eeac576c504b1fb840d4471e411 (diff)
Move some Task model methods to the TaskFinder class
Diffstat (limited to 'tests/units/TaskFinderTest.php')
-rw-r--r--tests/units/TaskFinderTest.php32
1 files changed, 32 insertions, 0 deletions
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']);
+ }
+}