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

View File

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

View File

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

View File

@ -351,6 +351,28 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('home', 'office'), $this->taskManager->projects()); $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 * @param string $string
* @return \DateTime * @return \DateTime