Exemplo n.º 1
0
 /**
  * @covers Thelia\Coupon\Type\RemoveXAmount::getToolTip
  */
 public function testGetToolTip()
 {
     $tooltip = 'This coupon will remove the entered amount to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.';
     $stubFacade = $this->generateFacadeStub(399, 'EUR', $tooltip);
     /** @var FacadeInterface $stubFacade */
     $coupon = new RemoveXAmount($stubFacade);
     $actual = $coupon->getToolTip();
     $expected = $tooltip;
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 2
0
 /**
  * @covers Thelia\Coupon\CouponManager::decrementQuantity
  */
 public function testDecrementeQuantityIllimited()
 {
     $stubFacade = $this->generateFacadeStub();
     $stubContainer = $this->getMock('\\Symfony\\Component\\DependencyInjection\\Container');
     $coupon = new RemoveXAmount($stubFacade);
     $date = new \DateTime();
     $coupon->set($stubFacade, 'XMAS', '', '', '', array('amount' => 21.0), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")), new ObjectCollection(), new ObjectCollection(), false);
     $condition1 = new MatchForTotalAmount($stubFacade);
     $operators = array(MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR, MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL);
     $values = array(MatchForTotalAmount::CART_TOTAL => 40.0, MatchForTotalAmount::CART_CURRENCY => 'EUR');
     $condition1->setValidatorsFromForm($operators, $values);
     $condition2 = new MatchForTotalAmount($stubFacade);
     $operators = array(MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR, MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL);
     $values = array(MatchForTotalAmount::CART_TOTAL => 400.0, MatchForTotalAmount::CART_CURRENCY => 'EUR');
     $condition2->setValidatorsFromForm($operators, $values);
     $conditions = new ConditionCollection();
     $conditions[] = $condition1;
     $conditions[] = $condition2;
     $coupon->setConditions($conditions);
     $stubFacade->expects($this->any())->method('getCurrentCoupons')->will($this->returnValue(array($coupon)));
     $stubContainer->expects($this->any())->method('get')->will($this->onConsecutiveCalls($stubFacade));
     $couponManager = new CouponManager($stubContainer);
     $stubModel = $this->getMockBuilder('\\Thelia\\Model\\Coupon')->disableOriginalConstructor()->getMock();
     $stubModel->expects($this->any())->method('getMaxUsage')->will($this->returnValue(-1));
     $stubModel->expects($this->any())->method('setMaxUsage')->will($this->returnValue(true));
     $actual = $couponManager->decrementQuantity($stubModel, null);
     $expected = false;
     $this->assertEquals($expected, $actual);
 }