From 32ddfb3fba9e0726623addd48ccd7af69e3b44f0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 4 Jul 2015 18:01:42 -0400 Subject: Allow search by task id --- tests/units/TaskFilterTest.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/units/TaskFilterTest.php') diff --git a/tests/units/TaskFilterTest.php b/tests/units/TaskFilterTest.php index 6a48f194..af00b6fa 100644 --- a/tests/units/TaskFilterTest.php +++ b/tests/units/TaskFilterTest.php @@ -27,6 +27,47 @@ class TaskFilterTest extends Base $this->assertEmpty($tf->search('search something')->findAll()); } + public function testSearchById() + { + $p = new Project($this->container); + $tc = new TaskCreation($this->container); + $tf = new TaskFilter($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1'))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2'))); + + $tf->search('#2'); + $tasks = $tf->findAll(); + $this->assertNotEmpty($tasks); + $this->assertCount(1, $tasks); + $this->assertEquals('task2', $tasks[0]['title']); + + $tf->search('1'); + $tasks = $tf->findAll(); + $this->assertNotEmpty($tasks); + $this->assertCount(1, $tasks); + $this->assertEquals('task1', $tasks[0]['title']); + + $tf->search('something'); + $tasks = $tf->findAll(); + $this->assertEmpty($tasks); + + $tf->search('#'); + $tasks = $tf->findAll(); + $this->assertEmpty($tasks); + + $tf->search('#abcd'); + $tasks = $tf->findAll(); + $this->assertEmpty($tasks); + + $tf->search('task1'); + $tasks = $tf->findAll(); + $this->assertNotEmpty($tasks); + $this->assertCount(1, $tasks); + $this->assertEquals('task1', $tasks[0]['title']); + } + public function testSearchWithReference() { $p = new Project($this->container); -- cgit v1.2.3