You are here

public function CommercePricelistRoleTestCaseSimpleProduct::testCommercePricelistSetRole in Commerce Pricelist 7

Test if the price of a product changes when a price list is assigned a role.

File

commerce_pricelist_role/tests/commerce_pricelist_role.test, line 41
Functional tests for the commerce pricelist role module.

Class

CommercePricelistRoleTestCaseSimpleProduct
Test price list features for a product display that only has one product attached.

Code

public function testCommercePricelistSetRole() {

  // Log in as a admin.
  $this
    ->drupalLogin($this->site_admin);
  $admin_role = key($this->site_admin->roles);
  $edit = array();

  // Enable pricelist for admin.
  $edit["commerce_pricelist_role[{$admin_role}]"] = TRUE;

  // Disable for anonymous.
  $edit['commerce_pricelist_role[1]'] = FALSE;
  $edit_path = 'admin/commerce/pricelist/commerce_pricelist_list/' . $this->pricelist_b->list_id . '/edit';

  // Submit pricelist form
  $this
    ->drupalPost($edit_path, $edit, t('Save'));
  $this
    ->assertText(t('Price list saved'), t('Saved pricelist B'));

  // Go to product display page
  $this
    ->drupalGet('node/' . $this->product_node->nid);
  $this
    ->assertText('$0.50', t('Product price was correctly set from price list.'));

  // Log out
  $this
    ->drupalLogout();

  // Go to product display page
  $this
    ->drupalGet('node/' . $this->product_node->nid);
  $this
    ->assertNoText('$0.50', t('Product price was correctly set from price list.'));
}