public function test_get_all() { $x = new SpecialAbility(); $x->characterId = $this->char->characterId; $created = array(); for ($i = 0; $i <= 10; $i++) { $xData = array('character_id' => $x->characterId, 'special_ability_name' => __METHOD__ . " #" . $i); $id = $x->create($this->dbObj, $xData); $this->assertTrue(is_numeric($id)); $this->assertTrue($id > 0); $data = $x->load($this->dbObj); $this->assertFalse(isset($created[$id])); $this->assertTrue(is_array($data)); $this->assertTrue(count($data) > 0); $created[$id] = $data; } $allRecs = $x->get_all($this->dbObj, $x->characterId); $this->assertEquals($i, count($allRecs)); $this->assertEquals(count($created), count($allRecs)); foreach ($created as $id => $data) { $this->assertTrue(isset($allRecs[$id])); $this->assertEquals($data, $allRecs[$id]); } }
public function load() { $retval = array(); if (is_numeric($this->characterId) && $this->characterId > 0) { $this->_char = new Character($this->characterId, $this->ownerUid, $this->dbObj); $this->_char->load($this->dbObj); $this->_abilities = Ability::get_all($this->dbObj, $this->characterId); $retval['abilities'] = $this->_abilities; $this->_armor = Armor::get_all($this->dbObj, $this->characterId); $retval['armor'] = $this->_armor; $this->_gear = Gear::get_all($this->dbObj, $this->characterId); $retval['gear'] = $this->_gear; $this->_saves = Save::get_all($this->dbObj, $this->characterId); $retval['saves'] = $this->_saves; $this->_skills = Skill::get_all($this->dbObj, $this->characterId); $retval['skills'] = $this->_skills; $this->_specialAbilities = SpecialAbility::get_all($this->dbObj, $this->characterId); $retval['specialAbilities'] = $this->_specialAbilities; $this->_weapons = Weapon::get_all($this->dbObj, $this->characterId); $retval['weapons'] = $this->_weapons; } else { throw new ErrorException(__METHOD__ . ": invalid character id"); } return $retval; }