You are here

public function CommerceCartTestCaseAttributes::testCommerceCartProductFormStructure in Commerce Core 7

Test the form structure of the Product.

File

modules/cart/tests/commerce_cart.test, line 440
Functional tests for the commerce cart module.

Class

CommerceCartTestCaseAttributes
Test cart features for a product with attributes.

Code

public function testCommerceCartProductFormStructure() {
  $this
    ->drupalGet('node/' . $this->product_node->nid);

  // Check whether the attribute selectors exist.
  $this
    ->assertField('edit-attributes-field-1', t('First attribute selector exists'));
  $this
    ->assertField('edit-attributes-field-2', t('Second attribute selector exists'));

  // Check the number of attributes.
  $options = $this
    ->xpath("//select[@id='edit-attributes-field-1']//option");
  $this
    ->assertEqual(count($options), count($this->fields['field_1']['settings']['allowed_values']), t('Number of options for first attribute match'));
  $options = $this
    ->xpath("//select[@id='edit-attributes-field-2']//option");
  $this
    ->assertEqual(count($options), count($this->fields['field_2']['settings']['allowed_values']), t('Number of options for second attribute match'));

  // Look for the Add to cart button.
  $this
    ->assertField('edit-submit', t('Add to cart button exists'));
}