fix tests
This commit is contained in:
parent
44d518e95a
commit
2dbcb2ca6a
|
@ -1,12 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace DavidBadura\Taskwarrior\Exception;
|
||||
|
||||
|
||||
/**
|
||||
* @author David Badura <d.a.badura@gmail.com>
|
||||
*/
|
||||
class ReferenceException extends TaskwarriorException
|
||||
{
|
||||
|
||||
}
|
|
@ -40,14 +40,14 @@ class DependsHandler implements SubscribingHandlerInterface
|
|||
'type' => 'Depends',
|
||||
'format' => 'json',
|
||||
'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
|
||||
'method' => 'deserializeCarbon'
|
||||
'method' => 'deserialize'
|
||||
);
|
||||
|
||||
$methods[] = array(
|
||||
'type' => 'Depends',
|
||||
'format' => 'json',
|
||||
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
|
||||
'method' => 'serializeCarbon'
|
||||
'method' => 'serialize'
|
||||
);
|
||||
|
||||
return $methods;
|
||||
|
@ -61,7 +61,7 @@ class DependsHandler implements SubscribingHandlerInterface
|
|||
* @return string
|
||||
* @throws ReferenceException
|
||||
*/
|
||||
public function serializeCarbon(VisitorInterface $visitor, $tasks, array $type, Context $context)
|
||||
public function serialize(VisitorInterface $visitor, $tasks, array $type, Context $context)
|
||||
{
|
||||
$list = [];
|
||||
|
||||
|
@ -82,10 +82,8 @@ class DependsHandler implements SubscribingHandlerInterface
|
|||
* @param array $type
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function deserializeCarbon(VisitorInterface $visitor, $data, array $type)
|
||||
public function deserialize(VisitorInterface $visitor, $data, array $type)
|
||||
{
|
||||
dump($data);
|
||||
|
||||
if (!$data) {
|
||||
return new ArrayCollection();
|
||||
}
|
||||
|
|
12
src/Task.php
12
src/Task.php
|
@ -301,6 +301,18 @@ class 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
|
||||
*/
|
||||
|
|
|
@ -340,7 +340,17 @@ class TaskManager
|
|||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -837,8 +837,6 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$this->taskManager->clear();
|
||||
$temp1 = $this->taskManager->find($task1->getUuid());
|
||||
|
||||
dump($temp1);
|
||||
|
||||
$this->assertCount(0, $temp1->getDependencies());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue