public function CommerceCartTestCaseMultiProducts::testCommerceCartProductFormStructure in Commerce Core 7
Test the structure of the product form.
File
- modules/
cart/ tests/ commerce_cart.test, line 235 - Functional tests for the commerce cart module.
Class
- CommerceCartTestCaseMultiProducts
- Test cart features for a product display that has several products attached.
Code
public function testCommerceCartProductFormStructure() {
$option_titles = array();
// Get the options of the product's select.
$options = $this
->xpath("//select[@id='edit-product-id']//option");
foreach ($options as $option) {
$option_titles[] = (string) $option;
}
// Check if the selector exists.
$this
->assertField('edit-product-id', t('The selector of products exists'));
// Check if the products actually are present in the selector.
$this
->assertTrue($this->product_titles == $option_titles, t('Correct products are present in the selector'));
// Look for the Add to cart button.
$this
->assertField('edit-submit', t('Add to cart button exists'));
}