From d18a3acca8d8fd1a30ea7fe742bf93dfa134edfd Mon Sep 17 00:00:00 2001 From: Tobias Olry Date: Sat, 25 Jul 2015 11:02:18 +0200 Subject: [PATCH 1/2] allow dots in projects and tasks --- src/TaskManager.php | 3 ++- tests/TaskManagerTest.php | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/TaskManager.php b/src/TaskManager.php index df091b8..1c5e06c 100644 --- a/src/TaskManager.php +++ b/src/TaskManager.php @@ -24,10 +24,11 @@ use ProxyManager\Proxy\ValueHolderInterface; /** * @author David Badura + * @author Tobias Olry */ class TaskManager { - const PATTERN = '/^[\wäüö]*$/i'; + const PATTERN = '/^[\wäüö\.]*$/i'; /** * @var Taskwarrior diff --git a/tests/TaskManagerTest.php b/tests/TaskManagerTest.php index c6e0fed..be5d351 100644 --- a/tests/TaskManagerTest.php +++ b/tests/TaskManagerTest.php @@ -9,7 +9,8 @@ use DavidBadura\Taskwarrior\Taskwarrior; use Symfony\Component\Filesystem\Filesystem; /** - * @author David Badura + * @author David Badura + * @author Tobias Olry */ class TaskManagerTest extends \PHPUnit_Framework_TestCase { @@ -548,7 +549,7 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('später'), $task1->getTags()); $this->assertEquals(array('später'), $this->taskwarrior->tags()); - $this->assertCount(1,$this->taskManager->filterPending('+später')); + $this->assertCount(1, $this->taskManager->filterPending('+später')); } public function testTagNameNotAllowed() @@ -563,6 +564,21 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->taskManager->save($task1); } + public function testProjectHierarchyAllowed() + { + $projects = ['grandparent.parent.child', 'parent.child']; + foreach ($projects as $project) { + $task = new Task(); + $task->setDescription('foo1'); + $task->setProject($project); + + // now exception thrown + $this->taskManager->save($task); + + $this->assertEquals($project, $task->getProject()); + } + } + public function testWait() { $task1 = new Task(); From 57441c8ed4d8f3d3a5a38d6a3c58845eff26d1f0 Mon Sep 17 00:00:00 2001 From: Tobias Olry Date: Wed, 29 Jul 2015 07:54:35 +0200 Subject: [PATCH 2/2] clear taskamanager and refetch data before asserting data was saved, extract test data into dataProvider --- tests/TaskManagerTest.php | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/TaskManagerTest.php b/tests/TaskManagerTest.php index be5d351..8792056 100644 --- a/tests/TaskManagerTest.php +++ b/tests/TaskManagerTest.php @@ -564,19 +564,31 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->taskManager->save($task1); } - public function testProjectHierarchyAllowed() + public function provideProjectNames() { - $projects = ['grandparent.parent.child', 'parent.child']; - foreach ($projects as $project) { - $task = new Task(); - $task->setDescription('foo1'); - $task->setProject($project); + return [ + ['grandparent.parent.child'], + ['parent.child'], + ]; + } - // now exception thrown - $this->taskManager->save($task); + /** + * @dataProvider provideProjectNames + */ + public function testProjectHierarchyAllowed($project) + { + $task = new Task(); + $task->setDescription('foo1'); + $task->setProject($project); - $this->assertEquals($project, $task->getProject()); - } + // no exception thrown + $this->taskManager->save($task); + + // refetch the task + $this->taskManager->clear(); + $task = $this->taskManager->find($task->getUuid()); + + $this->assertEquals($project, $task->getProject()); } public function testWait()