Esempio n. 1
0
 /**
  * @param Entity $task
  * @return Task
  */
 protected function _insert(Entity $task)
 {
     $this->_insertStmt->execute(array(':name' => $task->getName(), ':details' => $task->getDetails(), ':complete' => $task->isComplete()));
     $t = new Task(self::$_db->lastInsertId());
     $t->setName($task->getName());
     $t->setDetails($task->getDetails());
     $t->setComplete($task->isComplete());
     return $t;
 }
Esempio n. 2
0
 public function testCreateATaskEntity()
 {
     $tasks = array(array('id' => 1, 'name' => 'Get Milk', 'description' => '1 bag of skim milk', 'complete' => false), array('id' => 2, 'name' => 'Pay Cellphone Bill', 'description' => '$ 80.77', 'complete' => true));
     foreach ($tasks as $task) {
         $entity = new Task($task['id']);
         $entity->setName($task['name']);
         $entity->setDescription($task['description']);
         $entity->setComplete($task['complete']);
         $this->assertEquals($task['id'], $entity->getId());
         $this->assertEquals($task['name'], $entity->getName());
         $this->assertEquals($task['description'], $entity->getDescription());
         $this->assertEquals($task['complete'], $entity->isComplete());
     }
 }