public function CommerceDiscountUITest::testCommerceDiscountUIDisabledLineItemTypes in Commerce Discount 7
Test disabled line item types.
File
- tests/
commerce_discount_ui.test, line 241 - Commerce Discounts UI tests.
Class
- CommerceDiscountUITest
- Testing commerce discounts UI.
Code
public function testCommerceDiscountUIDisabledLineItemTypes() {
// Create the 30% discount and $1 product.
$this
->createDiscount('product_discount', 'percentage', 30, 'discount_30_off');
$product = $this
->createDummyProduct('TEST-PRODUCT', 'Test Product', 100);
// Create the order and apply discount.
$order = $this
->createDummyOrder($this->store_customer->uid, array(
$product->product_id => 1,
));
$order_wrapper = commerce_cart_order_refresh($order);
commerce_order_calculate_total($order);
// Ensure discount applied.
$line_item_wrapper = $order_wrapper->commerce_line_items
->get(0);
$unit_price = $line_item_wrapper->commerce_unit_price
->value();
$this
->assertEqual($unit_price['amount'], 70, 'Product line item unit price amount rounded properly for a 30% discount.');
// Login with store admin and turn off all line item types.
$this
->drupalLogin($this->store_admin);
$this
->drupalGet('admin/commerce/discounts/settings');
$values = array(
'commerce_discount_line_item_types[product_discount]' => FALSE,
'commerce_discount_line_item_types[product]' => FALSE,
);
$this
->drupalPost(NULL, $values, t('Save configuration'));
// Refresh the order and ensure the discount is no longer applicable.
$order_wrapper = commerce_cart_order_refresh($order);
$line_item_wrapper = $order_wrapper->commerce_line_items
->get(0);
$unit_price = $line_item_wrapper->commerce_unit_price
->value();
$this
->assertEqual($unit_price['amount'], 100, 'Product line item unit price is the original amount');
}