You are here

public function CommerceDiscountTest::testCommerceDiscountDiscountedProductPriceDisplay in Commerce Discount 7

Test discounted product price display.

File

tests/commerce_discount.test, line 310
Commerce Discounts tests.

Class

CommerceDiscountTest
Testing commerce discounts functionality.

Code

public function testCommerceDiscountDiscountedProductPriceDisplay() {

  // Create a product discount.
  $this
    ->createDiscount('product_discount', 'fixed_amount', 300);
  $formatted_discounted_price = '$7.00';

  // Log in as a normal user.
  $this
    ->drupalLogin($this->store_customer);
  $nid = $this->product_node->nid;

  // View a product node.
  $this
    ->drupalGet("node/{$nid}");
  $product_price = $this
    ->xpath('//div[contains(@class, "field-name-commerce-price")]/div[contains(@class, "field-item")]');
  $this
    ->assertTrue(trim((string) $product_price[0]->div) == $formatted_discounted_price, 'Discounted product price is shown on product page.');

  // Add a product to the cart.
  $this
    ->drupalPost('node/' . $this->product_node->nid, array(), t('Add to cart'));

  // View the cart.
  $this
    ->drupalGet('cart');
  $product_price = $this
    ->xpath('//td[contains(@class, "views-field-commerce-unit-price")]');
  $this
    ->assertTrue(trim((string) $product_price[0]->{0}) == $formatted_discounted_price, 'Discounted product price is shown on the cart.');
}