public function CommerceDiscountDateTest::testDiscountDateOrderDiscountInTime in Commerce Discount 7
Test order discount in timespan.
File
- tests/
commerce_discount_date.test, line 41 - Commerce Discounts date tests.
Class
- CommerceDiscountDateTest
- Testing commerce discount date functionality.
Code
public function testDiscountDateOrderDiscountInTime() {
// Create a discount valid from yesterday until tomorrow.
$start_time = time() - $this->dayInSeconds;
$end_time = time() + $this->dayInSeconds;
// Testing fixed discount.
$this
->createDateDiscount('order_discount', 'fixed_amount', 300, $start_time, $end_time);
// Create an order.
$order = $this
->createDummyOrder($this->store_customer->uid, array(
$this->product->product_id => 1,
), 'completed');
// Recalculate discounts.
$order_wrapper = commerce_cart_order_refresh($order);
// Check if the discount was applied on the order total price.
$this
->assertTrue($order_wrapper->commerce_order_total->amount
->value() == 700, 'Order discount is deducted when in time frame.');
}