You are here

public function CommercePriceTableTest::testCommercePriceTableCreateField in Commerce Price Table 7

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

File

tests/commerce_price_table.test, line 107
Functional tests for the commerce price table module.

Class

CommercePriceTableTest
Test price table features.

Code

public function testCommercePriceTableCreateField() {

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

  // Access product fields admin and check if the price table field is there.
  $this
    ->drupalGet('admin/commerce/products/types/product/fields');
  $this
    ->assertText('Price table', t('Price table field label found in the product fields admin screen'));
  $this
    ->assertText($this->field_name, t('Price table field name found in the product fields admin screen'));

  // Check if it's configured to unlimited.
  $this
    ->drupalGet('admin/commerce/products/types/product/fields/' . $this->field_name);
  $this
    ->assertOptionSelected('edit-field-cardinality', -1, t('Price table field is configured to have unlimited values'));

  // When creating a product, verify that the field is there.
  $this
    ->drupalGet('admin/commerce/products/add/product');
  $this
    ->assertText('Price table', t('Price table field label found in the add product form.'));
  $this
    ->assertFieldByName($this->field_name . '[und][0][amount]', NULL, t('Price table amount is present'));
  $this
    ->assertFieldByName($this->field_name . '[und][0][min_qty]', NULL, t('Price table min quantity is present'));
  $this
    ->assertFieldByName($this->field_name . '[und][0][max_qty]', NULL, t('Price table max quantity is present'));
  $this
    ->assertFieldById('edit-field-price-table-und-add-more', t('Add another item'), t('\'Add another item\' button is present'));
}