Пример #1
0
 /**
  * When a cart goes below 0 (due to discounts), set the amount to 0.
  *
  * @param CartInterface $cart Cart
  */
 public function validateNegativeAmount(CartInterface $cart)
 {
     $amount = $cart->getAmount();
     if ($amount->getAmount() <= 0) {
         $cart->setAmount(Money::create(0, $amount->getCurrency()));
     }
 }
Пример #2
0
 /**
  * Test result
  *
  * @param mixed $quantity the quantity to check against
  */
 public function assertResults($quantity)
 {
     if ($quantity > 0) {
         $cartLine = $this->cart->getCartLines()->first();
         $this->assertEquals($this->cart->getAmount(), $cartLine->getAmount());
         $this->assertEquals($this->cart->getAmount()->getAmount(), $cartLine->getPurchasable()->getPrice()->getAmount() * $quantity);
         $this->assertNotNull($cartLine->getId());
         $this->assertNotNull($this->cart->getId());
         $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->getObjectManager('cart')->getUnitOfWork()->getEntityState($this->cart));
     } else {
         $this->assertEmpty($this->cart->getCartLines());
         $this->assertEquals(0, $this->cart->getAmount()->getAmount());
         $this->assertEquals(UnitOfWork::STATE_NEW, $this->getObjectManager('cart_line')->getUnitOfWork()->getEntityState($this->cartLine));
     }
 }