public function CommerceDiscountTest::testCommerceDiscountOrderRefreshWrapper in Commerce Discount 7
Test order wrapper cache from order refresh.
File
- tests/
commerce_discount.test, line 68 - Commerce Discounts tests.
Class
- CommerceDiscountTest
- Testing commerce discounts functionality.
Code
public function testCommerceDiscountOrderRefreshWrapper() {
// Create a 'free bonus products' product discount.
$discount = $this
->createDiscount('order_discount', 'free_products', array(
$this->product->product_id,
));
// Create a completed order.
$order = $this
->createDummyOrder($this->store_customer->uid, array(
$this->product->product_id => 1,
), 'completed');
// Recalculate discounts.
$order_wrapper = commerce_cart_order_refresh($order);
$line_items = $order_wrapper
->value()->commerce_line_items[LANGUAGE_NONE];
$this
->assertEqual($order_wrapper->commerce_line_items
->count(), count($line_items), 'Number of line items matched');
// Disable the discount.
$discount->status = FALSE;
entity_save('commerce_discount', $discount);
$order_wrapper = commerce_cart_order_refresh($order);
$line_items = $order_wrapper
->value()->commerce_line_items[LANGUAGE_NONE];
$this
->assertEqual($order_wrapper->commerce_line_items
->count(), count($line_items), 'Number of line items matched');
}