Ejemplo n.º 1
0
 public function save(Task $task)
 {
     $sql = $this->getSaveSQL(!empty($task->getId()));
     $stmt = $this->pdo->prepare($sql);
     if ($isUpdate = $task->getId() !== 0) {
         $id = $task->getId();
         $stmt->bindParam(':id', $id, PDO::PARAM_INT);
     }
     $stmt->bindParam(':title', $title, PDO::PARAM_STR);
     $stmt->bindParam(':done', $done, PDO::PARAM_INT);
     $title = $task->getTitle();
     $done = $task->isDone();
     $success = $stmt->execute();
     if (false === $isUpdate) {
         $task->setId($this->pdo->lastInsertId());
     }
     return $task;
 }
Ejemplo n.º 2
0
 public function testMarkTaskAsDone()
 {
     $task = new Task('Foo Bar');
     $task->markAsDone();
     $this->assertTrue($task->isDone());
 }