/**
  * Insert a row in the characters table
  *
  * @param DatabaseConnection database class instance
  * @param array $params character attributes without id 
  * @return array row inserted of the database with that ID
  */
 public function postCharacter(DatabaseConnection $db, $params)
 {
     Character::insert($db, $params);
     $id = Character::lastID($db);
     $array = Character::find($db, $id);
     return $array;
 }
示例#2
0
 public function testUpdate()
 {
     require __DIR__ . '/config/database_test.php';
     $db = new DatabaseConnection($host, $database, $user, $password);
     $character1 = ['name' => 'Lion Woods', 'description' => 'A wonderful zombie that plays golf better than Tiger Woods', 'type' => 'zombie', 'dead' => '1', 'stage' => '2', 'hp' => '67'];
     $character2 = ['name' => 'Guybrush Threepwood', 'description' => 'How appropriate. You fight like a cow', 'type' => 'pirate', 'dead' => '0', 'stage' => '5', 'hp' => '100'];
     $id = Character::insert($db, $character1);
     Character::update($db, $id, $character2);
     $actual = Character::find($db, $id);
     $character2['id'] = $id;
     $expected = $character2;
     $this->assertEquals($expected, $actual, 'Character::update() not working properly');
 }