From 5b7e137f769e352e0dddeff6c0c9a19602a8e4d9 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 12 May 2017 15:55:13 -0400 Subject: Add wildcard search for task reference field (PR #3119) --- tests/units/Filter/TaskReferenceFilterTest.php | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/units/Filter/TaskReferenceFilterTest.php (limited to 'tests') 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 @@ +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()); + } +} -- cgit v1.2.3