diff options
author | Olivier Maridat <olivier.maridat@trialog.com> | 2015-11-26 15:33:44 +0100 |
---|---|---|
committer | Olivier Maridat <olivier.maridat@trialog.com> | 2015-11-26 15:33:44 +0100 |
commit | f837e70a2d74eb37c4c5de7e4f54c8bf8ec78db7 (patch) | |
tree | c146511e70537f7224835931ef1d3b0b2f516d3e /tests | |
parent | e582d4047b061f0c17e6366fed2bf1cabd624c10 (diff) |
Add filter by task link
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Core/LexerTest.php | 25 | ||||
-rw-r--r-- | tests/units/Model/TaskFilterTest.php | 60 |
2 files changed, 85 insertions, 0 deletions
diff --git a/tests/units/Core/LexerTest.php b/tests/units/Core/LexerTest.php index 9e14ff6b..55370aab 100644 --- a/tests/units/Core/LexerTest.php +++ b/tests/units/Core/LexerTest.php @@ -116,6 +116,31 @@ class LexerTest extends Base ); } + public function testLinkQuery() + { + $lexer = new Lexer; + + $this->assertEquals( + array(array('match' => 'link:', 'token' => 'T_LINK'), array('match' => 'is a milestone of', 'token' => 'T_STRING')), + $lexer->tokenize('link:"is a milestone of"') + ); + + $this->assertEquals( + array('T_LINK' => array('is a milestone of')), + $lexer->map($lexer->tokenize('link:"is a milestone of"')) + ); + + $this->assertEquals( + array('T_LINK' => array('is a milestone of', 'fixes')), + $lexer->map($lexer->tokenize('link:"is a milestone of" link:fixes')) + ); + + $this->assertEquals( + array(), + $lexer->map($lexer->tokenize('link: ')) + ); + } + public function testColumnQuery() { $lexer = new Lexer; diff --git a/tests/units/Model/TaskFilterTest.php b/tests/units/Model/TaskFilterTest.php index b668b7cc..daa193b2 100644 --- a/tests/units/Model/TaskFilterTest.php +++ b/tests/units/Model/TaskFilterTest.php @@ -6,6 +6,7 @@ use Kanboard\Model\Project; use Kanboard\Model\User; use Kanboard\Model\TaskFilter; use Kanboard\Model\TaskCreation; +use Kanboard\Model\TaskLink; use Kanboard\Core\DateParser; use Kanboard\Model\Category; use Kanboard\Model\Subtask; @@ -552,6 +553,65 @@ class TaskFilterTest extends Base $this->assertEquals('task3', $tasks[0]['title']); } + public function testSearchWithLink() + { + $p = new Project($this->container); + $u = new User($this->container); + $tc = new TaskCreation($this->container); + $tl = new TaskLink($this->container); + $tf = new TaskFilter($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertEquals(2, $u->create(array('username' => 'bob', 'name' => 'Bob Ryan'))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is awesome', 'color_id' => 'light_green'))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is amazing', 'color_id' => 'blue'))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'Bob at work'))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'I have a bad feeling about that'))); + $this->assertEquals(1, $tl->create(1, 2, 9)); // #1 is a milestone of #2 + $this->assertEquals(3, $tl->create(2, 1, 2)); // #2 blocks #1 + $this->assertEquals(5, $tl->create(3, 2, 2)); // #3 blocks #2 + + $tf->search('link:"is a milestone of"'); + $tasks = $tf->findAll(); + $this->assertNotEmpty($tasks); + $this->assertCount(1, $tasks); + $this->assertEquals('my task title is awesome', $tasks[0]['title']); + + $tf->search('link:"is a milestone of" amazing'); + $tasks = $tf->findAll(); + $this->assertEmpty($tasks); + + $tf->search('link:"unknown"'); + $tasks = $tf->findAll(); + $this->assertEmpty($tasks); + + $tf->search('link:unknown'); + $tasks = $tf->findAll(); + $this->assertEmpty($tasks); + + $tf->search('link:blocks amazing'); + $tasks = $tf->findAll(); + $this->assertNotEmpty($tasks); + $this->assertCount(1, $tasks); + $this->assertEquals('my task title is amazing', $tasks[0]['title']); + + $tf->search('link:"is a milestone of" link:blocks'); + $tasks = $tf->findAll(); + $this->assertNotEmpty($tasks); + $this->assertCount(3, $tasks); + $this->assertEquals('my task title is awesome', $tasks[0]['title']); + $this->assertEquals('my task title is amazing', $tasks[1]['title']); + $this->assertEquals('Bob at work', $tasks[2]['title']); + + $tf->search('link:"is a milestone of" link:blocks link:unknown'); + $tasks = $tf->findAll(); + $this->assertNotEmpty($tasks); + $this->assertCount(3, $tasks); + $this->assertEquals('my task title is awesome', $tasks[0]['title']); + $this->assertEquals('my task title is amazing', $tasks[1]['title']); + $this->assertEquals('Bob at work', $tasks[2]['title']); + } + public function testCopy() { $tf = new TaskFilter($this->container); |