public function create_defaults() { $abilities = new Ability(); $abilities->characterId = $this->characterId; $abilities->create_defaults($this->dbObj); $abilityCache = $abilities->get_all_abilities($this->dbObj); $skills = new Skill(); $skills->characterId = $this->characterId; foreach ($this->get_default_skill_list() as $k => $v) { $xData = array('character_id' => $this->characterId, 'skill_name' => $v[0], 'ability_id' => $abilityCache[$v[1]]); $skills->create($this->dbObj, $xData); } $saves = new Save(); $saves->characterId = $this->characterId; $saves->create_character_defaults($this->dbObj); //TODO: re-add logging // $log = new cs_webdblogger($this->dbObj, "Character", false); // $log->log_by_class("loaded defaults", "create"); return $this->load(); }
public function test_delete() { $x = new Save(); $x->characterId = $this->id; $y = new Ability(); $y->characterId = $this->id; $y->create_defaults($this->dbObj); $numCreated = $x->create_character_defaults($this->dbObj); $this->assertTrue(is_numeric($numCreated)); $this->assertTrue($numCreated > 0); $allSaves = $x->get_all($this->dbObj, $x->characterId); $numLeft = count($allSaves); foreach ($allSaves as $k => $data) { $this->assertEquals($numLeft, count($x->get_all($this->dbObj, $x->characterId))); $this->assertTrue(is_array($data)); $this->assertTrue(isset($data['character_save_id'])); $x->id = $data['character_save_id']; $this->assertEquals(1, $x->delete($this->dbObj)); $numLeft--; } $this->assertEquals(0, $numLeft); $this->assertEquals(array(), $x->get_all($this->dbObj, $x->characterId)); }