From fb763a765ee8a8a5daa4fab7f36f82e2edc5709f Mon Sep 17 00:00:00 2001 From: DavidBadura Date: Sun, 28 Jun 2015 13:11:00 +0000 Subject: [PATCH] fix description --- composer.json | 3 ++- src/Taskwarrior.php | 4 ++-- tests/TaskManagerTest.php | 36 ++++++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 755ccf6..15fd275 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "doctrine/collections": "~1.3" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.0", + "symfony/var-dumper": "~2.6" }, "autoload": { "psr-4": { diff --git a/src/Taskwarrior.php b/src/Taskwarrior.php index 92dab81..7c54969 100644 --- a/src/Taskwarrior.php +++ b/src/Taskwarrior.php @@ -180,7 +180,7 @@ class Taskwarrior if ($filter) { foreach($filter as $f) { - $parts[] = "( " . $f . ' )'; + $parts[] = "( " . $f . " )"; } } @@ -270,7 +270,7 @@ class Taskwarrior } if (array_key_exists('description', $params)) { - $options[] = $params['description']; + $options[] = 'description:' . $params['description']; } return $options; diff --git a/tests/TaskManagerTest.php b/tests/TaskManagerTest.php index 5ee8568..eca749d 100644 --- a/tests/TaskManagerTest.php +++ b/tests/TaskManagerTest.php @@ -69,30 +69,38 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($task, $result); } - public function testUrlInDescription() + public function provideDescriptions() { - $task = new Task(); - $task->setDescription('hier http://google.de '); - - $this->taskManager->save($task); - $this->taskManager->clear(); - - $result = $this->taskManager->find($task->getUuid()); - - $this->assertEquals('hier http://google.de ', $result->getDescription()); + return array( + array('hier http://google.de'), + array("test ' foo"), + array("test (foo) bar"), + array("foo-bar"), + array("test +bar") + ); } - public function testQuoteInDescription() + /** + * @dataProvider provideDescriptions + */ + public function testDescription($description) { $task = new Task(); - $task->setDescription(" test ' foo "); + $task->setDescription($description); $this->taskManager->save($task); $this->taskManager->clear(); - $result = $this->taskManager->find($task->getUuid()); + $task = $this->taskManager->find($task->getUuid()); - $this->assertEquals(" test ' foo ", $result->getDescription()); + $this->assertEquals($description, $task->getDescription()); + + $this->taskManager->save($task); + $this->taskManager->clear(); + + $task = $this->taskManager->find($task->getUuid()); + + $this->assertEquals($description, $task->getDescription()); } public function testSaveTaskWithoutDescription()