make clone possible

This commit is contained in:
DavidBadura 2015-02-06 18:01:04 +00:00
parent 9ef7c833f0
commit d2596a35f0
2 changed files with 36 additions and 0 deletions

View File

@ -262,4 +262,14 @@ class Task
{ {
return $this->status == self::STATUS_DELETED; return $this->status == self::STATUS_DELETED;
} }
/**
*
*/
public function __clone()
{
$this->uuid = null;
$this->entry = new \DateTime('now', new \DateTimeZone('UTC'));
$this->status = self::STATUS_PENDING;
}
} }

View File

@ -119,6 +119,32 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
$this->assertCount(1, $this->taskManager->filter()); $this->assertCount(1, $this->taskManager->filter());
} }
public function testClone()
{
$task = new Task();
$task->setDescription('foo');
$this->taskManager->save($task);
$this->assertCount(1, $this->taskManager->filter());
$task2 = clone $task;
$this->taskManager->save($task2);
$this->assertCount(2, $this->taskManager->filter());
$this->taskManager->done($task);
$this->isTrue($task->isCompleted());
$task3 = clone $task;
$this->isTrue($task3->isPending());
$this->taskManager->save($task3);
$this->isTrue($task->isCompleted());
$this->isTrue($task3->isPending());
}
public function testFilterAll() public function testFilterAll()
{ {
$task1 = new Task(); $task1 = new Task();