You are here

public function CommerceProductReferenceAdminTest::testCommerceProductReferenceCreateField in Commerce Core 7

Test if the field is correctly created and attached to the product display.

File

modules/product_reference/tests/commerce_product_reference.test, line 99
Tests for adding and displaying product reference fields.

Class

CommerceProductReferenceAdminTest
Functional tests for the Product Reference module.

Code

public function testCommerceProductReferenceCreateField() {

  // Check at database level.
  $this
    ->assertTrue(in_array($this->display_type->type, $this->field['bundles']['node']), t('Field is present in the product display bundle'));
  $this
    ->assertTrue($this->field_instance['field_name'] == $this->field_name, t('Field instance is present in the product display bundle'));

  // Check in the admin page for the content display.
  $this
    ->drupalGet('admin/structure/types/manage/' . strtr($this->display_type->type, '_', '-') . '/fields');
  $this
    ->assertText('Product', t('Reference product field label found'));
  $this
    ->assertText($this->field_name, t('Reference product field name found'));

  // The product selector should appear in the product display creation page.
  $this
    ->drupalGet('node/add/' . strtr($this->display_type->type, '_', '-'));
  $this
    ->assertFieldById('edit-field-product-und', NULL, t('Field selector is present in product display creation'));
}