You are here

function CommerceRecurringTestCase::testCommerceRecurringProductPriceListing in Commerce Recurring Framework 7.2

Test price list for recurring products.

File

tests/commerce_recurring.test, line 750
Unit tests for the commerce recurring module.

Class

CommerceRecurringTestCase
@file Unit tests for the commerce recurring module.

Code

function testCommerceRecurringProductPriceListing() {
  $this
    ->drupalLogin($this->customer);
  $recurring_product = $this
    ->createRecurringProduct();
  $this
    ->createDummyProductDisplayContentType('product_display', TRUE, 'field_product', FIELD_CARDINALITY_UNLIMITED);
  $node = $this
    ->createDummyProductNode(array(
    $recurring_product->product_id,
  ));
  $expected_price = commerce_currency_format($recurring_product->commerce_recurring_ini_price[LANGUAGE_NONE][0]['amount'], $recurring_product->commerce_recurring_ini_price[LANGUAGE_NONE][0]['currency_code']);

  // Check if the price is right in the product display page.
  // Price should be the initial one.
  $this
    ->drupalGet('node/' . $node->nid);

  // Add the cart block to the product page.
  $site_admin = $this
    ->createSiteAdmin();
  $this
    ->drupalLogin($site_admin);
  $this
    ->drupalGet('admin/structure/block/manage');
  $edit = array();
  $edit['blocks[commerce_cart_cart][region]'] = 'sidebar_first';
  $this
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));

  // Check if the price is right after adding the product to the cart.
  $this
    ->drupalLogin($this->customer);
  $this
    ->drupalPost('node/' . $node->nid, array(), t('Add to cart'));
  $this
    ->assertText($expected_price, t('Recurring product price in the display page (with cart) is the initial one as expected.'));
}