Exemplo n.º 1
0
 public function getCatalog()
 {
     $json = __DIR__ . '/../catalog.json';
     $array = json_decode(file_get_contents($json), true);
     $catalog = new Catalog();
     $catalog->import($array);
     return $catalog;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider testApplicableProvider
  * @group coupon
  */
 public function testApplicable($period, $products, $applied)
 {
     $term = new Term($period);
     $term->setPrice(12.0);
     $product = new \Cart\Catalog\Product();
     $product->setId(24);
     $product->getBilling()->addTerm($term);
     $catalog = new Catalog();
     $item = $catalog->getCartItem($product);
     $cart = $this->getCart();
     $cart->add($item);
     $total = $cart->total();
     $coupon = new Coupon('COUPON');
     $coupon->setProducts($products);
     $coupon->setType('PercentDiscount');
     $coupon->setConfig(['percent' => 50]);
     $coupon->calculateDiscount($cart);
     $this->assertEquals($total != $cart->total(), $applied);
 }
Exemplo n.º 3
0
 public function testGetCartItem()
 {
     $term = new Term(1);
     $product = new Product();
     $product->getBilling()->addTerm($term);
     $productDomain = new ProductDomain();
     $productDomain->getBilling()->addTerm($term);
     $productSharedHosting = new ProductSharedHosting();
     $productSharedHosting->getBilling()->addTerm($term);
     $productCpanelHosting = new ProductCpanelHosting();
     $productCpanelHosting->getBilling()->addTerm($term);
     $productVps = new ProductVps();
     $productVps->getBilling()->addTerm($term);
     $productSsl = new ProductSsl();
     $productSsl->getBilling()->addTerm($term);
     $catalog = new Catalog();
     $this->assertInstanceOf('\\Cart\\CartItem', $catalog->getCartItem($productCpanelHosting));
     $this->assertInstanceOf('\\Cart\\CartItem', $catalog->getCartItem($productSsl));
     $this->assertInstanceOf('\\Cart\\CartItemVps', $catalog->getCartItem($productVps));
     $this->assertInstanceOf('\\Cart\\CartItemSharedHosting', $catalog->getCartItem($productSharedHosting));
     $this->assertInstanceOf('\\Cart\\CartItemDomain', $catalog->getCartItem($productDomain));
     $this->assertInstanceOf('\\Cart\\CartItem', $catalog->getCartItem($product));
 }