summaryrefslogtreecommitdiff
path: root/tests/units/Filter
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-04-09 23:24:26 -0400
committerFrederic Guillot <fred@kanboard.net>2016-04-09 23:24:26 -0400
commit7705f4c533c3db726624e639be72fc9822904e96 (patch)
tree1410597fbc2c91570ff259b83d31ae0176c75558 /tests/units/Filter
parent11858be4e8d5aba983700c6cba1c4d0a33ea8e9d (diff)
Added search in comments
Diffstat (limited to 'tests/units/Filter')
-rw-r--r--tests/units/Filter/TaskCommentFilterTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/units/Filter/TaskCommentFilterTest.php b/tests/units/Filter/TaskCommentFilterTest.php
new file mode 100644
index 00000000..8d1b7f44
--- /dev/null
+++ b/tests/units/Filter/TaskCommentFilterTest.php
@@ -0,0 +1,52 @@
+<?php
+
+use Kanboard\Filter\TaskCommentFilter;
+use Kanboard\Model\Comment;
+use Kanboard\Model\Project;
+use Kanboard\Model\TaskCreation;
+use Kanboard\Model\TaskFinder;
+
+require_once __DIR__.'/../Base.php';
+
+class TaskCommentFilterTest extends Base
+{
+ public function testMatch()
+ {
+ $taskFinder = new TaskFinder($this->container);
+ $taskCreation = new TaskCreation($this->container);
+ $commentModel = new Comment($this->container);
+ $projectModel = new Project($this->container);
+ $query = $taskFinder->getExtendedQuery();
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1)));
+ $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'user_id' => 1, 'comment' => 'This is a test')));
+
+ $filter = new TaskCommentFilter();
+ $filter->withQuery($query);
+ $filter->withValue('test');
+ $filter->apply();
+
+ $this->assertCount(1, $query->findAll());
+ }
+
+ public function testNoMatch()
+ {
+ $taskFinder = new TaskFinder($this->container);
+ $taskCreation = new TaskCreation($this->container);
+ $commentModel = new Comment($this->container);
+ $projectModel = new Project($this->container);
+ $query = $taskFinder->getExtendedQuery();
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1)));
+ $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'user_id' => 1, 'comment' => 'This is a test')));
+
+ $filter = new TaskCommentFilter();
+ $filter->withQuery($query);
+ $filter->withValue('foobar');
+ $filter->apply();
+
+ $this->assertCount(0, $query->findAll());
+ }
+}