summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/units/LexerTest.php50
-rw-r--r--tests/units/TaskFilterTest.php70
2 files changed, 120 insertions, 0 deletions
diff --git a/tests/units/LexerTest.php b/tests/units/LexerTest.php
index 4d0d67ad..38974357 100644
--- a/tests/units/LexerTest.php
+++ b/tests/units/LexerTest.php
@@ -91,6 +91,56 @@ class LexerTest extends Base
);
}
+ public function testColumnQuery()
+ {
+ $lexer = new Lexer;
+
+ $this->assertEquals(
+ array(array('match' => 'column:', 'token' => 'T_COLUMN'), array('match' => 'Feature Request', 'token' => 'T_STRING')),
+ $lexer->tokenize('column:"Feature Request"')
+ );
+
+ $this->assertEquals(
+ array('T_COLUMN' => array('Feature Request')),
+ $lexer->map($lexer->tokenize('column:"Feature Request"'))
+ );
+
+ $this->assertEquals(
+ array('T_COLUMN' => array('Feature Request', 'Bug')),
+ $lexer->map($lexer->tokenize('column:"Feature Request" column:Bug'))
+ );
+
+ $this->assertEquals(
+ array(),
+ $lexer->map($lexer->tokenize('column: '))
+ );
+ }
+
+ public function testProjectQuery()
+ {
+ $lexer = new Lexer;
+
+ $this->assertEquals(
+ array(array('match' => 'project:', 'token' => 'T_PROJECT'), array('match' => 'My project', 'token' => 'T_STRING')),
+ $lexer->tokenize('project:"My project"')
+ );
+
+ $this->assertEquals(
+ array('T_PROJECT' => array('My project')),
+ $lexer->map($lexer->tokenize('project:"My project"'))
+ );
+
+ $this->assertEquals(
+ array('T_PROJECT' => array('My project', 'plop')),
+ $lexer->map($lexer->tokenize('project:"My project" project:plop'))
+ );
+
+ $this->assertEquals(
+ array(),
+ $lexer->map($lexer->tokenize('project: '))
+ );
+ }
+
public function testStatusQuery()
{
$lexer = new Lexer;
diff --git a/tests/units/TaskFilterTest.php b/tests/units/TaskFilterTest.php
index 33e1792e..c68e8880 100644
--- a/tests/units/TaskFilterTest.php
+++ b/tests/units/TaskFilterTest.php
@@ -124,6 +124,76 @@ class TaskFilterTest extends Base
$this->assertEmpty($tasks);
}
+ public function testSearchWithProject()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'My project A')));
+ $this->assertEquals(2, $p->create(array('name' => 'My project B')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1')));
+ $this->assertNotFalse($tc->create(array('project_id' => 2, 'title' => 'task2')));
+
+ $tf->search('project:"My project A"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('My project A', $tasks[0]['project_name']);
+
+ $tf->search('project:2');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task2', $tasks[0]['title']);
+ $this->assertEquals('My project B', $tasks[0]['project_name']);
+
+ $tf->search('project:"My project A" project:"my project b"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(2, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('My project A', $tasks[0]['project_name']);
+ $this->assertEquals('task2', $tasks[1]['title']);
+ $this->assertEquals('My project B', $tasks[1]['project_name']);
+
+ $tf->search('project:"not found"');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+ }
+
+ public function testSearchWithColumn()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'My project A')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2', 'column_id' => 3)));
+
+ $tf->search('column:Backlog');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(1, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('Backlog', $tasks[0]['column_name']);
+
+ $tf->search('column:backlog column:"Work in progress"');
+ $tasks = $tf->findAll();
+ $this->assertNotEmpty($tasks);
+ $this->assertCount(2, $tasks);
+ $this->assertEquals('task1', $tasks[0]['title']);
+ $this->assertEquals('Backlog', $tasks[0]['column_name']);
+ $this->assertEquals('task2', $tasks[1]['title']);
+ $this->assertEquals('Work in progress', $tasks[1]['column_name']);
+
+ $tf->search('column:"not found"');
+ $tasks = $tf->findAll();
+ $this->assertEmpty($tasks);
+ }
+
public function testSearchWithDueDate()
{
$dp = new DateParser($this->container);