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'); }
/** * Update a character with that ID * * @param DatabaseConnection database class instance * @param mixed $id number, could be a string or an int * @param array $params character attributes without id * @return array Row of character modified */ public function putCharacter(DatabaseConnection $db, $id, $params) { Character::update($db, $id, $params); $character = Character::find($db, $id); return $character; }