diff --git a/src/Task.php b/src/Task.php index 110b769..666f340 100644 --- a/src/Task.php +++ b/src/Task.php @@ -278,9 +278,8 @@ class Task $this->recur = new Recurring($recur); } elseif ($recur instanceof Recurring) { $this->recur = $recur; - } else { - throw new TaskwarriorException(); - + } elseif ($this->recur && is_null($recur)) { + throw new TaskwarriorException('You cannot remove the recurrence from a recurring task.'); } } diff --git a/src/Taskwarrior.php b/src/Taskwarrior.php index 726b425..a7c4f6b 100644 --- a/src/Taskwarrior.php +++ b/src/Taskwarrior.php @@ -40,19 +40,19 @@ class Taskwarrior } /** - * @param string $uuid + * @param string $filter */ - public function delete($uuid) + public function delete($filter) { - $this->command('delete', $uuid); + $this->command('delete', $filter); } /** - * @param string $uuid + * @param string $filter */ - public function done($uuid) + public function done($filter) { - $this->command('done', $uuid); + $this->command('done', $filter); } /** diff --git a/tests/TaskManagerTest.php b/tests/TaskManagerTest.php index 98dcd3c..12e4fec 100644 --- a/tests/TaskManagerTest.php +++ b/tests/TaskManagerTest.php @@ -461,6 +461,8 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->taskManager->clear(); $task1 = $this->taskManager->find($task1->getUuid()); + + $this->assertTrue(is_array($task1->getTags())); $this->assertEmpty($task1->getTags()); $task1->removeTag('a'); @@ -527,6 +529,32 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($result[0]->isPending()); } + public function testRecurringException() + { + $this->setExpectedException('DavidBadura\Taskwarrior\TaskwarriorException'); + + $task1 = new Task(); + $task1->setDescription('foo1'); + $task1->setDue('tomorrow'); + $task1->setRecurring('daily'); + + $this->taskManager->save($task1); + + $task1->setRecurring(null); + } + + public function testRecurringNull() + { + $task1 = new Task(); + $task1->setDescription('foo1'); + $task1->setDue('tomorrow'); + $task1->setRecurring(null); + + $this->taskManager->save($task1); + + $this->assertCount(1, $this->taskManager->filterAll()); + } + public function testRecurringModify() { $recur1 = new Recurring(Recurring::DAILY);