summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-21 22:44:25 -0400
committerFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-21 22:44:25 -0400
commit919e5d51a4cc4a2928cd34c8c575d4c003bb9a74 (patch)
treeacc8c0312f8efe6d32dd97355754b663c7b383e7 /tests
parent9bfd824ab724dc2eb356e06b1722f843dbd8d96d (diff)
Add a method to apply filters for tasks
Diffstat (limited to 'tests')
-rw-r--r--tests/TaskTest.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/TaskTest.php b/tests/TaskTest.php
index 5ddb1860..8218a5cf 100644
--- a/tests/TaskTest.php
+++ b/tests/TaskTest.php
@@ -7,6 +7,35 @@ use Model\Project;
class TaskTest extends Base
{
+ public function testFilter()
+ {
+ $t = new Task($this->db, $this->event);
+ $p = new Project($this->db, $this->event);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(1, $t->create(array('title' => 'test a', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
+ $this->assertEquals(2, $t->create(array('title' => 'test b', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
+
+ $tasks = $t->find(array(array('column' => 'project_id', 'operator' => 'eq', 'value' => '1')));
+ $this->assertEquals(2, count($tasks));
+ $this->assertEquals(1, $tasks[0]['id']);
+ $this->assertEquals(2, $tasks[1]['id']);
+
+ $tasks = $t->find(array(
+ array('column' => 'project_id', 'operator' => 'eq', 'value' => '1'),
+ array('column' => 'owner_id', 'operator' => 'eq', 'value' => '2'),
+ ));
+ $this->assertEquals(1, count($tasks));
+ $this->assertEquals(2, $tasks[0]['id']);
+
+ $tasks = $t->find(array(
+ array('column' => 'project_id', 'operator' => 'eq', 'value' => '1'),
+ array('column' => 'title', 'operator' => 'like', 'value' => '%b%'),
+ ));
+ $this->assertEquals(1, count($tasks));
+ $this->assertEquals(2, $tasks[0]['id']);
+ }
+
public function testDateFormat()
{
$t = new Task($this->db, $this->event);