/** * @param Task $old * @param Task $new */ private function merge(Task $old, Task $new) { $this->setValue($old, 'urgency', $new->getUrgency()); $this->setValue($old, 'status', $new->getStatus()); $this->setValue($old, 'modified', $new->getModified()); $this->setValue($old, 'start', $new->getStart()); if ($new->isPending()) { // fix reopen problem $this->setValue($old, 'end', null); } else { $this->setValue($old, 'end', $new->getEnd()); } }
public function testAnnotation() { $task = new Task(); $task->setDescription('foo'); $task->addAnnotation(new Annotation('testbar')); $this->taskManager->save($task); $task = $this->taskManager->find($task->getUuid()); $annotations = $task->getAnnotations(); $this->assertCount(1, $annotations); $this->assertEquals('testbar', $annotations[0]->getDescription()); $task->addAnnotation(new Annotation('blabla')); $this->taskManager->save($task); $task = $this->taskManager->find($task->getUuid()); $annotations = $task->getAnnotations(); $this->assertCount(2, $annotations); $this->assertEquals('testbar', $annotations[0]->getDescription()); $this->assertEquals('blabla', $annotations[1]->getDescription()); $task->removeAnnotation($annotations[0]); $this->taskManager->save($task); $task = $this->taskManager->find($task->getUuid()); $annotations = $task->getAnnotations(); $this->assertCount(1, $annotations); $this->assertEquals('blabla', $annotations[0]->getDescription()); $task->setAnnotations([new Annotation('foo'), new Annotation('bar')]); $this->taskManager->save($task); $task = $this->taskManager->find($task->getUuid()); $annotations = $task->getAnnotations(); $this->assertCount(2, $annotations); $this->assertEquals('foo', $annotations[0]->getDescription()); $this->assertEquals('bar', $annotations[1]->getDescription()); }