Fixed search query with multiple assignees (nested OR conditions)

This commit is contained in:
Frederic Guillot
2016-07-16 19:15:26 -04:00
parent 4364559805
commit 3aa0f85748
5 changed files with 38 additions and 10 deletions

View File

@@ -17,6 +17,7 @@ Improvements:
Bug fixes: Bug fixes:
* Fixed search query with multiple assignees (nested OR conditions)
* Fixed Markdown editor auto-grow on the task form (Safari) * Fixed Markdown editor auto-grow on the task form (Safari)
* Fixed compatibility issue with PHP 5.3 for OAuthUserProvider class * Fixed compatibility issue with PHP 5.3 for OAuthUserProvider class

View File

@@ -27,7 +27,7 @@
"eluceo/ical": "0.10.1", "eluceo/ical": "0.10.1",
"erusev/parsedown" : "1.6.0", "erusev/parsedown" : "1.6.0",
"fguillot/json-rpc" : "1.2.1", "fguillot/json-rpc" : "1.2.1",
"fguillot/picodb" : "1.0.13", "fguillot/picodb" : "1.0.14",
"fguillot/simpleLogger" : "1.0.1", "fguillot/simpleLogger" : "1.0.1",
"fguillot/simple-validator" : "1.0.1", "fguillot/simple-validator" : "1.0.1",
"fguillot/simple-queue" : "1.0.1", "fguillot/simple-queue" : "1.0.1",

14
composer.lock generated
View File

@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "77e9464e13331b1dec5c810d1c186ebf", "hash": "daa76b43d528f87e3bed91133fdb9259",
"content-hash": "0d13e80c805e296f3765cc329d51358a", "content-hash": "dde1b92fc6f9ca106cf927f4cd141a21",
"packages": [ "packages": [
{ {
"name": "christian-riesen/base32", "name": "christian-riesen/base32",
@@ -245,16 +245,16 @@
}, },
{ {
"name": "fguillot/picodb", "name": "fguillot/picodb",
"version": "v1.0.13", "version": "v1.0.14",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/fguillot/picoDb.git", "url": "https://github.com/fguillot/picoDb.git",
"reference": "e8e02cd6a170811eed6c70d1edcbb419818d303a" "reference": "86a831302ab10af800c83dbe4b3b01c88d5433f1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/e8e02cd6a170811eed6c70d1edcbb419818d303a", "url": "https://api.github.com/repos/fguillot/picoDb/zipball/86a831302ab10af800c83dbe4b3b01c88d5433f1",
"reference": "e8e02cd6a170811eed6c70d1edcbb419818d303a", "reference": "86a831302ab10af800c83dbe4b3b01c88d5433f1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -281,7 +281,7 @@
], ],
"description": "Minimalist database query builder", "description": "Minimalist database query builder",
"homepage": "https://github.com/fguillot/picoDb", "homepage": "https://github.com/fguillot/picoDb",
"time": "2016-07-13 02:11:01" "time": "2016-07-16 22:59:59"
}, },
{ {
"name": "fguillot/simple-queue", "name": "fguillot/simple-queue",

View File

@@ -8,6 +8,7 @@ use Kanboard\Filter\TaskTitleFilter;
use Kanboard\Model\ProjectModel; use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskCreationModel; use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel; use Kanboard\Model\TaskFinderModel;
use Kanboard\Model\UserModel;
class LexerBuilderTest extends Base class LexerBuilderTest extends Base
{ {
@@ -123,4 +124,29 @@ class LexerBuilderTest extends Base
$this->assertCount(1, $tasks); $this->assertCount(1, $tasks);
$this->assertEquals('Test', $tasks[0]['title']); $this->assertEquals('Test', $tasks[0]['title']);
} }
public function testWithOrCriteria()
{
$taskFinder = new TaskFinderModel($this->container);
$taskCreation = new TaskCreationModel($this->container);
$projectModel = new ProjectModel($this->container);
$userModel = new UserModel($this->container);
$query = $taskFinder->getExtendedQuery();
$this->assertEquals(2, $userModel->create(array('username' => 'foobar', 'name' => 'Foo Bar')));
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
$this->assertEquals(1, $taskCreation->create(array('title' => 'Test 1', 'project_id' => 1, 'owner_id' => 2)));
$this->assertEquals(2, $taskCreation->create(array('title' => 'Test 2', 'project_id' => 1, 'owner_id' => 1)));
$this->assertEquals(3, $taskCreation->create(array('title' => 'Test 3', 'project_id' => 1, 'owner_id' => 0)));
$builder = new LexerBuilder();
$builder->withFilter(new TaskAssigneeFilter());
$builder->withFilter(new TaskTitleFilter(), true);
$builder->withQuery($query);
$tasks = $builder->build('assignee:admin assignee:foobar')->toArray();
$this->assertCount(2, $tasks);
$this->assertEquals('Test 1', $tasks[0]['title']);
$this->assertEquals('Test 2', $tasks[1]['title']);
}
} }

View File

@@ -22,8 +22,9 @@ class OrCriteriaTest extends Base
$this->assertEquals(2, $userModel->create(array('username' => 'foobar', 'name' => 'Foo Bar'))); $this->assertEquals(2, $userModel->create(array('username' => 'foobar', 'name' => 'Foo Bar')));
$this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); $this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
$this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'owner_id' => 2))); $this->assertEquals(1, $taskCreation->create(array('title' => 'Test 1', 'project_id' => 1, 'owner_id' => 2)));
$this->assertEquals(2, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'owner_id' => 1))); $this->assertEquals(2, $taskCreation->create(array('title' => 'Test 2', 'project_id' => 1, 'owner_id' => 1)));
$this->assertEquals(3, $taskCreation->create(array('title' => 'Test 3', 'project_id' => 1, 'owner_id' => 0)));
$criteria = new OrCriteria(); $criteria = new OrCriteria();
$criteria->withQuery($query); $criteria->withQuery($query);