fix tests

This commit is contained in:
DavidBadura 2015-07-08 11:55:42 +02:00
parent 44d518e95a
commit 2dbcb2ca6a
5 changed files with 34 additions and 18 deletions

View File

@ -1,12 +1,10 @@
<?php <?php
/**
*
*/
namespace DavidBadura\Taskwarrior\Exception; namespace DavidBadura\Taskwarrior\Exception;
/**
* @author David Badura <d.a.badura@gmail.com>
*/
class ReferenceException extends TaskwarriorException class ReferenceException extends TaskwarriorException
{ {
} }

View File

@ -40,14 +40,14 @@ class DependsHandler implements SubscribingHandlerInterface
'type' => 'Depends', 'type' => 'Depends',
'format' => 'json', 'format' => 'json',
'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
'method' => 'deserializeCarbon' 'method' => 'deserialize'
); );
$methods[] = array( $methods[] = array(
'type' => 'Depends', 'type' => 'Depends',
'format' => 'json', 'format' => 'json',
'direction' => GraphNavigator::DIRECTION_SERIALIZATION, 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
'method' => 'serializeCarbon' 'method' => 'serialize'
); );
return $methods; return $methods;
@ -61,7 +61,7 @@ class DependsHandler implements SubscribingHandlerInterface
* @return string * @return string
* @throws ReferenceException * @throws ReferenceException
*/ */
public function serializeCarbon(VisitorInterface $visitor, $tasks, array $type, Context $context) public function serialize(VisitorInterface $visitor, $tasks, array $type, Context $context)
{ {
$list = []; $list = [];
@ -82,10 +82,8 @@ class DependsHandler implements SubscribingHandlerInterface
* @param array $type * @param array $type
* @return ArrayCollection * @return ArrayCollection
*/ */
public function deserializeCarbon(VisitorInterface $visitor, $data, array $type) public function deserialize(VisitorInterface $visitor, $data, array $type)
{ {
dump($data);
if (!$data) { if (!$data) {
return new ArrayCollection(); return new ArrayCollection();
} }

View File

@ -301,6 +301,18 @@ class Task
$this->depends->removeElement($task); $this->depends->removeElement($task);
} }
/**
* @param Task[] $tasks
*/
public function setDependencies(array $tasks)
{
$this->depends = new ArrayCollection();
foreach ($tasks as $task) {
$this->addDependency($task);
}
}
/** /**
* @return Recurring * @return Recurring
*/ */

View File

@ -340,7 +340,17 @@ class TaskManager
{ {
$json = $this->taskwarrior->export($filter); $json = $this->taskwarrior->export($filter);
return $this->getSerializer()->deserialize($json, 'array<DavidBadura\Taskwarrior\Task>', 'json'); $tasks = $this->getSerializer()->deserialize($json, 'array<DavidBadura\Taskwarrior\Task>', 'json');
foreach ($tasks as $task) {
if ($task->getDependencies()) {
continue;
}
$task->setDependencies(array());
}
return $tasks;
} }
/** /**

View File

@ -837,8 +837,6 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->taskManager->clear(); $this->taskManager->clear();
$temp1 = $this->taskManager->find($task1->getUuid()); $temp1 = $this->taskManager->find($task1->getUuid());
dump($temp1);
$this->assertCount(0, $temp1->getDependencies()); $this->assertCount(0, $temp1->getDependencies());
} }