예제 #1
0
 public function itemsJSON($app)
 {
     $items = Description::find('all');
     $items = array_unique(array_map(function ($desc) {
         return $desc->name;
     }, $items));
     $app->output->json($items);
 }
예제 #2
0
 function test_run_ageIsThere()
 {
     Initial::addData();
     $character = Finalize::run();
     $id = $character->getDescriptionId();
     $description = Description::find($id);
     $age = $description->getAge();
     $result = "21";
     $this->assertEquals($age, $result);
 }
예제 #3
0
 public function __construct(Branch $branch, Category $category, Product $product, Images $image, Brand $brand, Order $order, Order_Detail $order_detail, Coupon $coupon, Users $user, Discount $discount, Banner $banner, Description $description)
 {
     $this->branch = $branch;
     $this->category = $category;
     $this->product = $product;
     $this->image = $image;
     $this->brand = $brand;
     $this->order = $order;
     $this->order_detail = $order_detail;
     $this->coupon = $coupon;
     $this->user = $user;
     $this->discount = $discount;
     $this->banner = $banner;
     $this->beforeFilter(function () {
         $this->banner_list = $this->banner->GetAllBanner(50);
         $this->website_description = Description::find(1);
         $branch_list = $this->branch->GetAllBranch();
         $result = array();
         foreach ($branch_list as $list) {
             $result[$list->name] = $this->category->GetAllCatLev1FromBranchID($list->id);
         }
         $this->result = $result;
         $this->listBrand = $this->brand->GetAllBrand();
         $this->user_info = Session::get('user_info');
         //cart
         $this->cart = Session::get('giay.cart');
         $this->total = 0;
         for ($i = 0; $i < count($this->cart); $i++) {
             $this->total += $this->cart[$i]['total'];
         }
         //coupon
         $this->coupon_percentage = Session::get('giay.coupon');
         if ($this->coupon_percentage != '') {
             $this->total_final = $this->total - $this->coupon_percentage * $this->total / 100;
         } else {
             $this->total_final = $this->total;
         }
         //coupon_code
         $this->coupon_code = Session::get('giay.coupon_code');
     });
 }
예제 #4
0
 function getOther()
 {
     $id = $this->getDescriptionId();
     $description = Description::find($id);
     $other = $description->getOther();
     return $other;
 }
예제 #5
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;
 }
예제 #6
0
 function test_find()
 {
     //Arrange
     $name = "Mike";
     $gender = "male";
     $age = "25";
     $alignment = "LG";
     $height = "6ft 1in";
     $eye_color = "hazel";
     $hair_color = "brown";
     $skin_tone = "dark";
     $other = "stuff";
     $test_description = new Description($name, $gender, $age, $alignment, $height, $eye_color, $hair_color, $skin_tone, $other);
     $test_description->save();
     $name2 = "Michael";
     $gender2 = "female";
     $age2 = "30";
     $alignment2 = "CG";
     $height2 = "6ft 1in";
     $eye_color2 = "brown";
     $hair_color2 = "black";
     $skin_tone2 = "copper";
     $other2 = "more stuff";
     $test_description2 = new Description($name2, $gender2, $age2, $alignment2, $height2, $eye_color2, $hair_color2, $skin_tone2, $other2);
     $test_description2->save();
     //Act
     $result = Description::find($test_description->getId());
     //Assert
     $this->assertEquals($test_description, $result);
 }