Пример #1
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);
 }
Пример #2
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));
 }