fix until & recurring

This commit is contained in:
DavidBadura 2015-02-08 18:32:51 +00:00
parent 85132b8189
commit 3fa353d533
4 changed files with 58 additions and 1 deletions

View File

@ -261,7 +261,7 @@ class Task
} }
/** /**
* @return string * @return Recurring
*/ */
public function getRecurring() public function getRecurring()
{ {

View File

@ -196,6 +196,8 @@ class TaskManager
'tags' => $task->getTags(), 'tags' => $task->getTags(),
'due' => $task->getDue() ? $task->getDue()->format('Ymd\THis\Z') : null, 'due' => $task->getDue() ? $task->getDue()->format('Ymd\THis\Z') : null,
'wait' => $task->getWait() ? $task->getWait()->format('Ymd\THis\Z') : null, 'wait' => $task->getWait() ? $task->getWait()->format('Ymd\THis\Z') : null,
'until' => $task->getUntil() ? $task->getUntil()->format('Ymd\THis\Z') : null,
'recur' => $task->getRecurring() ? $task->getRecurring()->getValue() : null,
], ],
$task->getUuid() $task->getUuid()
); );

View File

@ -205,6 +205,10 @@ class Taskwarrior
$options[] = 'until:' . $params['until']; $options[] = 'until:' . $params['until'];
} }
if (array_key_exists('recur', $params)) {
$options[] = 'recur:' . $params['recur'];
}
if (array_key_exists('project', $params)) { if (array_key_exists('project', $params)) {
$options[] = 'project:' . $params['project']; $options[] = 'project:' . $params['project'];
} }

View File

@ -2,6 +2,7 @@
namespace DavidBadura\Taskwarrior\Test; namespace DavidBadura\Taskwarrior\Test;
use DavidBadura\Taskwarrior\Recurring;
use DavidBadura\Taskwarrior\Task; use DavidBadura\Taskwarrior\Task;
use DavidBadura\Taskwarrior\TaskManager; use DavidBadura\Taskwarrior\TaskManager;
use DavidBadura\Taskwarrior\Taskwarrior; use DavidBadura\Taskwarrior\Taskwarrior;
@ -526,6 +527,31 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($result[0]->isPending()); $this->assertTrue($result[0]->isPending());
} }
public function testRecurringModify()
{
$recur1 = new Recurring(Recurring::DAILY);
$recur2 = new Recurring(Recurring::WEEKLY);
$task1 = new Task();
$task1->setDescription('foo1');
$task1->setDue('tomorrow');
$task1->setRecurring($recur1);
$this->taskManager->save($task1);
$this->taskManager->clear();
$task1 = $this->taskManager->find($task1->getUuid());
$this->assertEquals($recur1, $task1->getRecurring());
$task1->setRecurring($recur2);
$this->taskManager->save($task1);
$this->taskManager->clear();
$task1 = $this->taskManager->find($task1->getUuid());
$this->assertEquals($recur2, $task1->getRecurring());
}
public function testUntil() public function testUntil()
{ {
$task1 = new Task(); $task1 = new Task();
@ -541,6 +567,31 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->assertCount(0, $this->taskManager->filter()); $this->assertCount(0, $this->taskManager->filter());
} }
public function testUntilModify()
{
$date1 = $this->createDateTime('tomorrow');
$date2 = $this->createDateTime('+2 day');
$task1 = new Task();
$task1->setDescription('foo1');
$task1->setUntil($date1);
$this->taskManager->save($task1);
$this->taskManager->clear();
$task1 = $this->taskManager->find($task1->getUuid());
$this->assertEquals($date1, $task1->getUntil());
$task1->setUntil($date2);
$this->taskManager->save($task1);
$this->taskManager->clear();
$task1 = $this->taskManager->find($task1->getUuid());
$this->assertEquals($date2, $task1->getUntil());
}
/** /**
* @param string $string * @param string $string
* @return \DateTime * @return \DateTime