Пример #1
0
 public function testCreateAndRetrieve()
 {
     // set up currency
     if (ActiveRecord::objectExists('Currency', 'USD')) {
         $this->usd = Currency::getInstanceByID('USD', Currency::LOAD_DATA);
     } else {
         $this->usd = Currency::getNewInstance('USD');
         $this->usd->setAsDefault();
         $this->usd->save();
     }
     $products = array();
     for ($k = 0; $k <= 2; $k++) {
         $products[$k] = Product::getNewInstance($this->root);
         $products[$k]->setPrice($this->usd, $k + 1);
         $products[$k]->save();
         $bundled = ProductBundle::getNewInstance($this->container, $products[$k]);
         $bundled->save();
     }
     $list = ProductBundle::getBundledProductSet($this->container);
     $this->assertEqual($list->size(), count($products));
     foreach ($list as $index => $item) {
         $this->assertSame($item->relatedProduct->get(), $products[$index]);
     }
     $this->assertEqual(ProductBundle::getTotalBundlePrice($this->container, $this->usd), 6);
 }
Пример #2
0
 public function getBundledProducts()
 {
     if (is_null($this->bundledProducts)) {
         ClassLoader::import('application.model.product.ProductBundle');
         $this->bundledProducts = ProductBundle::getBundledProductSet($this);
     }
     return $this->bundledProducts;
 }