fix recurring tasks

This commit is contained in:
DavidBadura 2015-04-03 14:11:02 +00:00
parent 4a36d7e511
commit 44274c6fc2
3 changed files with 36 additions and 9 deletions

View File

@ -278,9 +278,8 @@ class Task
$this->recur = new Recurring($recur); $this->recur = new Recurring($recur);
} elseif ($recur instanceof Recurring) { } elseif ($recur instanceof Recurring) {
$this->recur = $recur; $this->recur = $recur;
} else { } elseif ($this->recur && is_null($recur)) {
throw new TaskwarriorException(); throw new TaskwarriorException('You cannot remove the recurrence from a recurring task.');
} }
} }

View File

@ -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);
} }
/** /**

View File

@ -461,6 +461,8 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->taskManager->clear(); $this->taskManager->clear();
$task1 = $this->taskManager->find($task1->getUuid()); $task1 = $this->taskManager->find($task1->getUuid());
$this->assertTrue(is_array($task1->getTags()));
$this->assertEmpty($task1->getTags()); $this->assertEmpty($task1->getTags());
$task1->removeTag('a'); $task1->removeTag('a');
@ -527,6 +529,32 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($result[0]->isPending()); $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() public function testRecurringModify()
{ {
$recur1 = new Recurring(Recurring::DAILY); $recur1 = new Recurring(Recurring::DAILY);