summaryrefslogtreecommitdiff
path: root/tests/TaskTest.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-27 15:14:13 -0400
committerFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-27 15:14:13 -0400
commit096b282a473fa2b27c3bfe3061f54b5fd83c75e0 (patch)
treefc358e47860c50ab8505e0666043d76196e48016 /tests/TaskTest.php
parent6551609d1b248011d301080c1be7c48085dc5d55 (diff)
Add a basic task search
Diffstat (limited to 'tests/TaskTest.php')
-rw-r--r--tests/TaskTest.php43
1 files changed, 41 insertions, 2 deletions
diff --git a/tests/TaskTest.php b/tests/TaskTest.php
index 0c5e2496..701ba611 100644
--- a/tests/TaskTest.php
+++ b/tests/TaskTest.php
@@ -13,8 +13,8 @@ class TaskTest extends Base
$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)));
+ $this->assertEquals(1, $t->create(array('title' => 'test a', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'description' => 'biloute')));
+ $this->assertEquals(2, $t->create(array('title' => 'test b', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2, 'description' => 'toto et titi sont dans un bateau')));
$tasks = $t->find(array(array('column' => 'project_id', 'operator' => 'eq', 'value' => '1')));
$this->assertEquals(2, count($tasks));
@@ -34,6 +34,45 @@ class TaskTest extends Base
));
$this->assertEquals(1, count($tasks));
$this->assertEquals(2, $tasks[0]['id']);
+
+ // Condition with OR
+ $search = 'bateau';
+ $filters = array(
+ array('column' => 'project_id', 'operator' => 'eq', 'value' => 1),
+ 'or' => array(
+ array('column' => 'title', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ array('column' => 'description', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ )
+ );
+
+ $tasks = $t->find($filters);
+ $this->assertEquals(1, count($tasks));
+ $this->assertEquals(2, $tasks[0]['id']);
+
+ $search = 'toto et titi';
+ $filters = array(
+ array('column' => 'project_id', 'operator' => 'eq', 'value' => 1),
+ 'or' => array(
+ array('column' => 'title', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ array('column' => 'description', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ )
+ );
+
+ $tasks = $t->find($filters);
+ $this->assertEquals(1, count($tasks));
+ $this->assertEquals(2, $tasks[0]['id']);
+
+ $search = 'john';
+ $filters = array(
+ array('column' => 'project_id', 'operator' => 'eq', 'value' => 1),
+ 'or' => array(
+ array('column' => 'title', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ array('column' => 'description', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ )
+ );
+
+ $tasks = $t->find($filters);
+ $this->assertEquals(0, count($tasks));
}
public function testDateFormat()