summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-05-12 15:55:13 -0400
committerFrederic Guillot <fred@kanboard.net>2017-05-12 15:55:13 -0400
commit5b7e137f769e352e0dddeff6c0c9a19602a8e4d9 (patch)
tree19c38daad18475b623fc713392fc51419a3c029a /tests/units
parent630f4ee780f3a9240ae9296e73f7518f21ae23ae (diff)
Add wildcard search for task reference field (PR #3119)
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/Filter/TaskReferenceFilterTest.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/units/Filter/TaskReferenceFilterTest.php b/tests/units/Filter/TaskReferenceFilterTest.php
new file mode 100644
index 00000000..49a86454
--- /dev/null
+++ b/tests/units/Filter/TaskReferenceFilterTest.php
@@ -0,0 +1,65 @@
+<?php
+
+use Kanboard\Filter\TaskReferenceFilter;
+use Kanboard\Model\ProjectModel;
+use Kanboard\Model\TaskCreationModel;
+use Kanboard\Model\TaskFinderModel;
+
+require_once __DIR__.'/../Base.php';
+
+class TaskReferenceFilterTest extends Base
+{
+ public function testWithoutMatch()
+ {
+ $taskFinder = new TaskFinderModel($this->container);
+ $taskCreation = new TaskCreationModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $query = $taskFinder->getExtendedQuery();
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1)));
+
+ $filter = new TaskReferenceFilter();
+ $filter->withQuery($query);
+ $filter->withValue('aaa-bbb');
+ $filter->apply();
+
+ $this->assertCount(0, $query->findAll());
+ }
+
+ public function testWithExactMatch()
+ {
+ $taskFinder = new TaskFinderModel($this->container);
+ $taskCreation = new TaskCreationModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $query = $taskFinder->getExtendedQuery();
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'reference' => 'aaa-bbb')));
+
+ $filter = new TaskReferenceFilter();
+ $filter->withQuery($query);
+ $filter->withValue('aaa-bbb');
+ $filter->apply();
+
+ $this->assertCount(1, $query->findAll());
+ }
+
+ public function testWithWildCard()
+ {
+ $taskFinder = new TaskFinderModel($this->container);
+ $taskCreation = new TaskCreationModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $query = $taskFinder->getExtendedQuery();
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
+ $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'reference' => 'aaa-bbb')));
+
+ $filter = new TaskReferenceFilter();
+ $filter->withQuery($query);
+ $filter->withValue('aaa-*');
+ $filter->apply();
+
+ $this->assertCount(1, $query->findAll());
+ }
+}