public function test_gear_total_weight() { $char = new Character(__METHOD__, 1, $this->dbObj); $gear = new Gear(); $gear->characterId = $char->characterId; $createThis = array('torches', 'silk rope', 'bullseye lantern'); $manualWeight = 0; $testData = array(); foreach ($createThis as $name) { $_createData = array('character_id' => $char->characterId, 'gear_name' => $name, 'weight' => rand(1, 10), 'quantity' => rand(1, 10)); $manualWeight += $_createData['weight'] * $_createData['quantity']; $id = $gear->create($this->dbObj, $_createData); $this->assertTrue(is_numeric($id)); $this->assertTrue($id > 0); $this->assertFalse(isset($testData[$id])); $testData[$id] = $gear->load($this->dbObj); $this->assertTrue(is_array($testData[$id])); $this->assertTrue(count($testData[$id]) > 0); } $this->assertEquals(count($testData), count($createThis)); $allGear = Gear::get_all($this->dbObj, $char->id); $this->assertEquals(count($allGear), count($testData)); $manualWeight = 0; foreach ($testData as $k => $v) { $this->assertTrue(isset($allGear[$id])); $this->assertTrue(is_array($allGear[$id])); $this->assertEquals($v, $allGear[$k]); } $this->assertEquals($manualWeight, $char->get_total_weight($this->dbObj)); }