public function CommercePriceTableTest::testCommercePriceTableHideOriginalPrice in Commerce Price Table 7
Hide the original price.
File
- tests/
commerce_price_table.test, line 256 - Functional tests for the commerce price table module.
Class
- CommercePriceTableTest
- Test price table features.
Code
public function testCommercePriceTableHideOriginalPrice() {
$this
->drupalGet('admin/commerce/products/' . $this->product->product_id . '/edit');
$this
->drupalGet('node/' . $this->product_node->nid);
// Access the field admin page to check if the hide option is there.
$this
->drupalGet('admin/commerce/products/types/product/fields/' . $this->field_name);
$this
->assertFieldByName('instance[settings][commerce_price_table][hide_default_price]', NULL, t('Hide option for original price is present in the field admin page.'));
// Enable hide original price.
$edit = array(
'instance[settings][commerce_price_table][hide_default_price]' => 1,
);
$this
->drupalPost(NULL, $edit, t('Save settings'));
// Check if the checkbox is selected.
$this
->drupalGet('admin/commerce/products/types/product/fields/' . $this->field_name);
$this
->assertFieldByName('instance[settings][commerce_price_table][hide_default_price]', 1, t('Hide option for original price is selected.'));
// Access product edit, price textfield should be hidden.
$this
->drupalGet('admin/commerce/products/' . $this->product->product_id . '/edit');
$price_field = $this
->xpath("//input[@id='edit-commerce-price-und-0-amount']");
$this
->assertTrue(empty($price_field), t('Original price field is hidden in the product edit page.'));
// Access product display, original price shouldn't be there.
$this
->drupalGet('node/' . $this->product_node->nid);
$this
->assertNoRaw(drupal_render(field_view_field('commerce_product', $this->product, 'commerce_price')), t('Original price is not displayed in the product display'));
}