public function CommerceProductReferenceAdminTest::testCommerceProductReferenceTitleNoLinkFormatter in Commerce Core 7
Test the title no link formatter.
File
- modules/
product_reference/ tests/ commerce_product_reference.test, line 384 - Tests for adding and displaying product reference fields.
Class
- CommerceProductReferenceAdminTest
- Functional tests for the Product Reference module.
Code
public function testCommerceProductReferenceTitleNoLinkFormatter() {
// Go to manage fields screen of the product display.
$this
->drupalGet('admin/structure/types/manage/' . strtr($this->display_type->type, '_', '-') . '/display');
// Change the default value for SKU with link.
$this
->drupalPost(NULL, array(
'fields[field_product][type]' => 'commerce_product_reference_title_plain',
), t('Save'));
// Check if the value has been saved.
$this
->assertText(t('Your settings have been saved.'), t('Settings saved message displayed'));
$this
->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_title_plain', t('Correct value is selected.'));
// Clear field's cache and reload field instance information just saved.
field_cache_clear();
$field_instance = field_info_instance('node', $this->field_name, $this->display_type->type);
// Check if the value has been stored in db.
$this
->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_title_plain', t('Option correctly stored in db'));
// Create a product display using one product already generated.
$product = reset($this->products);
$product_node = $this
->createDummyProductNode(array(
$product->product_id,
), $product->title);
// Access to the product display node.
$this
->drupalGet('node/' . $product_node->nid);
// Generate and check the expected ouptut.
$render = array(
'#markup' => check_plain($product->title),
);
$this
->assertRaw(drupal_render($render), t('Title with no Link is displayed correctly'));
}