public function testGeneral()
 {
     $description = new Description();
     $this->assertNotEmpty($description->getGlue());
     $description->clear();
     $this->assertEmpty($description->getVars());
     $description->add('test');
     $this->assertNotEmpty($description->getVars());
     $description->render();
     $description->setVars(['abc', 'zyz']);
     $this->assertNotEmpty($description->getVars());
     $this->assertNotEmpty($description->render());
 }
Example #2
0
 private function formatInventory($inventory, $descriptions)
 {
     $inventory_items = $inventory;
     $inventory_descs = $descriptions ?: null;
     $inventory = array();
     foreach ($inventory_items as $item_id => &$item) {
         try {
             // Search for item description in DB
             $desc_id = $item->classid . '_' . $item->instanceid;
             // Remap item ids for items with multiple potential ids
             if (!empty(self::$ITEM_MAP[$desc_id])) {
                 $desc_id = self::$ITEM_MAP[$desc_id];
             }
             $desc = Description::find($desc_id);
         } catch (ActiveRecord\RecordNotFound $e) {
             // If there isn't any item information for this item and no existing
             // information exists, ignore this item
             if (empty($inventory_descs)) {
                 $desc = null;
             } else {
                 $desc = Description::add($desc_id, $inventory_descs->{$desc_id});
             }
         }
         // If a tag isn't allowed, the item will not show up in the inventory
         if (empty($desc)) {
             continue;
         }
         $item->desc = $desc;
         $inventory[$item->id] = $item;
     }
     return $inventory;
 }