summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-28 21:04:37 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-28 21:04:37 -0400
commit7c1222fc595091d9e292bae9d563a3fdaf660d7b (patch)
treeffdb99b873ab1269b637e9f2cee879777803b03a /tests/units
parent2e7e7031804b09a04c83896535b31acb12138960 (diff)
Add description attribute for advanced search
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/LexerTest.php20
-rw-r--r--tests/units/TaskFilterTest.php21
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/units/LexerTest.php b/tests/units/LexerTest.php
index 7ba3801c..e2b97566 100644
--- a/tests/units/LexerTest.php
+++ b/tests/units/LexerTest.php
@@ -96,6 +96,26 @@ class LexerTest extends Base
);
}
+ public function testDescriptionQuery()
+ {
+ $lexer = new Lexer;
+
+ $this->assertEquals(
+ array(array('match' => 'description:', 'token' => 'T_DESCRIPTION'), array('match' => 'my text search', 'token' => 'T_STRING')),
+ $lexer->tokenize('description:"my text search"')
+ );
+
+ $this->assertEquals(
+ array('T_DESCRIPTION' => 'my text search'),
+ $lexer->map($lexer->tokenize('description:"my text search"'))
+ );
+
+ $this->assertEquals(
+ array(),
+ $lexer->map($lexer->tokenize('description: '))
+ );
+ }
+
public function testDueDateQuery()
{
$lexer = new Lexer;
diff --git a/tests/units/TaskFilterTest.php b/tests/units/TaskFilterTest.php
index 4f826cd2..494a0f1b 100644
--- a/tests/units/TaskFilterTest.php
+++ b/tests/units/TaskFilterTest.php
@@ -53,6 +53,27 @@ class TaskFilterTest extends Base
$this->assertCount(1, $tasks);
}
+ public function testSearchWithDescription()
+ {
+ $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', 'description' => '**something to do**')));
+
+ $tf->search('description:"something"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task2', $tasks[0]['title']);
+
+ $tf->search('description:"rainy day"');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+ }
+
public function testSearchWithDueDate()
{
$dp = new DateParser($this->container);