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
/**
*
*/
namespace DavidBadura\Taskwarrior\Exception;
/**
* @author David Badura <d.a.badura@gmail.com>
*/
class ReferenceException extends TaskwarriorException
{
}
}

View File

@ -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();
}

View File

@ -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
*/
@ -462,4 +474,4 @@ class Task
$this->entry = new Carbon('now');
$this->status = self::STATUS_PENDING;
}
}
}

View File

@ -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;
}
/**
@ -482,4 +492,4 @@ class TaskManager
{
return new self(new Taskwarrior());
}
}
}

View File

@ -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());
}
@ -850,4 +848,4 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
{
return new \Carbon\Carbon($string);
}
}
}