diff --git a/src/Task.php b/src/Task.php index b456661..4d92cff 100644 --- a/src/Task.php +++ b/src/Task.php @@ -262,4 +262,14 @@ class Task { 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; + } } \ No newline at end of file diff --git a/tests/TaskManagerTest.php b/tests/TaskManagerTest.php index 0db3f95..2fa1db4 100644 --- a/tests/TaskManagerTest.php +++ b/tests/TaskManagerTest.php @@ -119,6 +119,32 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $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() { $task1 = new Task();