Free shipping for selected countries and/or shipping methods

This commit is contained in:
Franck Allimant
2014-05-15 20:25:22 +02:00
parent 32542efe28
commit 392abff271
31 changed files with 414 additions and 106 deletions

View File

@@ -196,7 +196,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
321,
$this->orderEvent->getOrder()->chosenDeliveryAddress
$this->orderEvent->getOrder()->getChoosenDeliveryAddress()
);
}
@@ -208,7 +208,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
654,
$this->orderEvent->getOrder()->chosenInvoiceAddress
$this->orderEvent->getOrder()->getChoosenInvoiceAddress()
);
}
@@ -263,8 +263,8 @@ class OrderTest extends \PHPUnit_Framework_TestCase
$paymentModuleClass = $paymentModule->getFullNamespace();
$this->container->set(sprintf('module.%s', $paymentModule->getCode()), new $paymentModuleClass());
$this->orderEvent->getOrder()->chosenDeliveryAddress = $validDeliveryAddress->getId();
$this->orderEvent->getOrder()->chosenInvoiceAddress = $validInvoiceAddress->getId();
$this->orderEvent->getOrder()->setChoosenDeliveryAddress($validDeliveryAddress->getId());
$this->orderEvent->getOrder()->setChoosenInvoiceAddress($validInvoiceAddress->getId());
$this->orderEvent->getOrder()->setDeliveryModuleId($deliveryModule->getId());
$this->orderEvent->getOrder()->setPostage(20);
$this->orderEvent->getOrder()->setPaymentModuleId($paymentModule->getId());

View File

@@ -11,6 +11,7 @@
/*************************************************************************************/
namespace Thelia\Coupon;
use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Condition\ConditionCollection;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\ConditionFactory;
@@ -18,7 +19,9 @@ use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Operators;
use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Model\Coupon;
use Thelia\Model\CouponCountry;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Order;
/**
* Unit Test CouponManager Class
@@ -167,8 +170,13 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$actual = $couponManager->getDiscount();
$expected = 21 + 21.50;
$order = new Order();
$order->setChoosenDeliveryAddress(1);
$order->setDeliveryModuleId(1);
$this->assertEquals($expected, $actual);
$this->assertTrue($couponManager->isCouponRemovingPostage());
$this->assertTrue($couponManager->isCouponRemovingPostage($order));
}
/**
@@ -390,7 +398,12 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$coupon = new RemoveXAmount($stubFacade);
$date = new \DateTime();
$coupon->set($stubFacade, 'XMAS', '', '', '', array('amount' => 21.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$coupon->set(
$stubFacade, 'XMAS', '', '', '', array('amount' => 21.00),
true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")),
new ObjectCollection(),
new ObjectCollection()
);
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(
@@ -455,7 +468,12 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$coupon = new RemoveXAmount($stubFacade);
$date = new \DateTime();
$coupon->set($stubFacade, 'XMAS', '', '', '', array('amount' => 21.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$coupon->set(
$stubFacade, 'XMAS', '', '', '', array('amount' => 21.00),
true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")),
new ObjectCollection(),
new ObjectCollection()
);
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(

View File

@@ -11,6 +11,7 @@
/*************************************************************************************/
namespace Thelia\Coupon\Type;
use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Condition\ConditionCollection;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\Implementation\MatchForTotalAmount;
@@ -114,7 +115,12 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.';
$coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $description, array('amount' => 10.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$coupon->set(
$stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)',
$description, array('amount' => 10.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")),
new ObjectCollection(),
new ObjectCollection()
);
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(

View File

@@ -11,6 +11,7 @@
/*************************************************************************************/
namespace Thelia\Coupon\Type;
use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Condition\ConditionCollection;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\Implementation\MatchForTotalAmount;
@@ -103,7 +104,13 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.';
$coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $description, array('amount' => 0.00, 'percentage' => 10.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
$coupon->set(
$stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)',
$description, array('amount' => 0.00, 'percentage' => 10.00), true, true, true, true,
254, $date->setTimestamp(strtotime("today + 3 months")),
new ObjectCollection(),
new ObjectCollection()
);
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(