summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-07-04 18:01:42 -0400
committerFrederic Guillot <fred@kanboard.net>2015-07-04 18:01:42 -0400
commit32ddfb3fba9e0726623addd48ccd7af69e3b44f0 (patch)
tree2137a21d4703820adc4c9589bb2140df9849755f /tests/units
parent198f3eda90807c0295a013cd4ebdc3806545d608 (diff)
Allow search by task id
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/LexerTest.php5
-rw-r--r--tests/units/TaskFilterTest.php41
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/units/LexerTest.php b/tests/units/LexerTest.php
index 0e3a61ae..bf0ffdd0 100644
--- a/tests/units/LexerTest.php
+++ b/tests/units/LexerTest.php
@@ -341,6 +341,11 @@ class LexerTest extends Base
);
$this->assertEquals(
+ array('T_TITLE' => '#123'),
+ $lexer->map($lexer->tokenize('#123'))
+ );
+
+ $this->assertEquals(
array(),
$lexer->map($lexer->tokenize('color:assignee:'))
);
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);