summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/units/LexerTest.php30
-rw-r--r--tests/units/TaskFilterTest.php27
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/units/LexerTest.php b/tests/units/LexerTest.php
index 4abe451b..7ba3801c 100644
--- a/tests/units/LexerTest.php
+++ b/tests/units/LexerTest.php
@@ -66,6 +66,36 @@ class LexerTest extends Base
);
}
+ public function testStatusQuery()
+ {
+ $lexer = new Lexer;
+
+ $this->assertEquals(
+ array(array('match' => 'status:', 'token' => 'T_STATUS'), array('match' => 'open', 'token' => 'T_STRING')),
+ $lexer->tokenize('status:open')
+ );
+
+ $this->assertEquals(
+ array(array('match' => 'status:', 'token' => 'T_STATUS'), array('match' => 'closed', 'token' => 'T_STRING')),
+ $lexer->tokenize('status:closed')
+ );
+
+ $this->assertEquals(
+ array('T_STATUS' => 'open'),
+ $lexer->map($lexer->tokenize('status:open'))
+ );
+
+ $this->assertEquals(
+ array('T_STATUS' => 'closed'),
+ $lexer->map($lexer->tokenize('status:closed'))
+ );
+
+ $this->assertEquals(
+ array(),
+ $lexer->map($lexer->tokenize('status: '))
+ );
+ }
+
public function testDueDateQuery()
{
$lexer = new Lexer;
diff --git a/tests/units/TaskFilterTest.php b/tests/units/TaskFilterTest.php
index 4e2366e5..4f826cd2 100644
--- a/tests/units/TaskFilterTest.php
+++ b/tests/units/TaskFilterTest.php
@@ -26,6 +26,33 @@ class TaskFilterTest extends Base
$this->assertEmpty($tf->search('search something')->findAll());
}
+ public function testSearchWithStatus()
+ {
+ $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' => 'my task title is awesome')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is amazing')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is amazing', 'is_active' => 0)));
+
+ $tf->search('status:open');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(2, $tasks);
+
+ $tf->search('status:plop');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(3, $tasks);
+
+ $tf->search('status:closed');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ }
+
public function testSearchWithDueDate()
{
$dp = new DateParser($this->container);