You are here

public function CommerceDiscountDateTest::testDiscountDateOrderDiscountOutOfTime in Commerce Discount 7

Test order discount out of timespan.

File

tests/commerce_discount_date.test, line 60
Commerce Discounts date tests.

Class

CommerceDiscountDateTest
Testing commerce discount date functionality.

Code

public function testDiscountDateOrderDiscountOutOfTime() {

  // Create a discount valid from tomorrow.
  $start_time = time() + $this->dayInSeconds;
  $end_time = time() + 2 * $this->dayInSeconds;

  // Testing fixed discount.
  // Create a fixed order discount of $3 limited to one use.
  $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');
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

  // Check if the discount was applied on the order total price.
  $this
    ->assertTrue($order_wrapper->commerce_order_total->amount
    ->value() == 1000, 'Order discount is ignored when out of time frame.');
}