summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Filter/TaskReferenceFilter.php8
-rw-r--r--tests/units/Filter/TaskReferenceFilterTest.php19
2 files changed, 27 insertions, 0 deletions
diff --git a/app/Filter/TaskReferenceFilter.php b/app/Filter/TaskReferenceFilter.php
index 2fe6f8a6..612be812 100644
--- a/app/Filter/TaskReferenceFilter.php
+++ b/app/Filter/TaskReferenceFilter.php
@@ -32,6 +32,14 @@ class TaskReferenceFilter extends BaseFilter implements FilterInterface
*/
public function apply()
{
+ if ($this->value === 'none') {
+ $this->query->beginOr();
+ $this->query->eq(TaskModel::TABLE.'.reference', '');
+ $this->query->isNull(TaskModel::TABLE.'.reference');
+ $this->query->closeOr();
+ return $this;
+ }
+
if (strpos($this->value, '*') >= 0) {
$this->query->ilike(TaskModel::TABLE.'.reference', str_replace('*', '%', $this->value));
return $this;
diff --git a/tests/units/Filter/TaskReferenceFilterTest.php b/tests/units/Filter/TaskReferenceFilterTest.php
index 49a86454..016f69c4 100644
--- a/tests/units/Filter/TaskReferenceFilterTest.php
+++ b/tests/units/Filter/TaskReferenceFilterTest.php
@@ -62,4 +62,23 @@ class TaskReferenceFilterTest extends Base
$this->assertCount(1, $query->findAll());
}
+
+ public function testWithNone()
+ {
+ $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' => 'A', 'project_id' => 1, 'reference' => 'aaa-bbb')));
+ $this->assertEquals(2, $taskCreation->create(array('title' => 'B', 'project_id' => 1)));
+
+ $filter = new TaskReferenceFilter();
+ $filter->withQuery($query);
+ $filter->withValue('none');
+ $filter->apply();
+
+ $this->assertCount(1, $query->findAll());
+ }
}