add priority

This commit is contained in:
DavidBadura 2015-02-06 17:05:29 +00:00
parent c2983029ce
commit b81cad6243
4 changed files with 55 additions and 1 deletions

View File

@ -14,6 +14,10 @@ class Task
const STATUS_DELETED = 'deleted';
const STATUS_WAITING = 'waiting';
const PRIORITY_LOW = 'L';
const PRIORITY_MEDIUM = 'M';
const PRIORITY_HIGH = 'H';
/**
* @var string
*
@ -28,6 +32,13 @@ class Task
*/
private $description;
/**
* @var string
*
* @JMS\Type(name="string")
*/
private $priority;
/**
* @var string
*
@ -97,6 +108,22 @@ class Task
$this->description = $description;
}
/**
* @return string
*/
public function getPriority()
{
return $this->priority;
}
/**
* @param string $priority
*/
public function setPriority($priority)
{
$this->priority = $priority;
}
/**
* @return string
*/

View File

@ -191,6 +191,7 @@ class TaskManager
[
'description' => $task->getDescription(),
'project' => $task->getProject(),
'priority' => $task->getPriority(),
'due' => $task->getDue() ? $task->getDue()->format('Ymd\THis\Z') : null,
],
$task->getUuid()

View File

@ -66,6 +66,10 @@ class Taskwarrior
$options[] = 'project:' . $params['project'];
}
if (array_key_exists('priority', $params)) {
$options[] = 'priority:' . $params['priority'];
}
if (array_key_exists('description', $params)) {
$options[] = $params['description'];
}
@ -85,7 +89,7 @@ class Taskwarrior
}
/**
* @param $json
* @param string $json
* @return string
* @throws TaskwarriorException
*/

View File

@ -351,6 +351,28 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('home', 'office'), $this->taskManager->projects());
}
public function testPriority()
{
$task1 = new Task();
$task1->setDescription('foo1');
$task1->setPriority(Task::PRIORITY_MEDIUM);
$this->taskManager->save($task1);
$this->taskManager->clear();
$task1 = $this->taskManager->find($task1->getUuid());
$this->assertEquals(Task::PRIORITY_MEDIUM, $task1->getPriority());
$task1->setPriority(Task::PRIORITY_HIGH);
$this->taskManager->save($task1);
$this->taskManager->clear();
$task1 = $this->taskManager->find($task1->getUuid());
$this->assertEquals(Task::PRIORITY_HIGH, $task1->getPriority());
}
/**
* @param string $string
* @return \DateTime