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 handle_new_record($type, $name, array $extraData = null)
 {
     if (is_null($extraData) || !is_array($extraData)) {
         $extraData = array();
     }
     $extraData['character_id'] = $this->characterId;
     $log = new cs_webdblogger($this->dbObj, "Character");
     switch ($type) {
         case Weapon::sheetIdPrefix:
             $x = new Weapon();
             $extraData['weapon_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case Armor::sheetIdPrefix:
             $x = new Armor();
             $extraData['armor_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case SpecialAbility::sheetIdPrefix:
             $x = new SpecialAbility();
             $extraData['special_ability_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case Gear::sheetIdPrefix:
             $x = new Gear();
             $extraData['gear_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         case Skill::sheetIdPrefix:
             $x = new Skill();
             $extraData['skill_name'] = $name;
             $result = $x->create($this->dbObj, $extraData);
             break;
         default:
             $details = __METHOD__ . ": invalid type (" . $type . ")";
             $log->log_by_class($details, "exception in code");
             throw new InvalidArgumentException($details);
     }
     $details = "New record, type=(" . $type . "), name=(" . $name . ")";
     if (is_array($details) && count($extraData) > 0) {
         $details .= implode(", ", $extraData);
     }
     $log->log_by_class($details, "create");
     return $result;
 }