public function ProductAttributeTest::testProductVariationTypes in Commerce Core 8.2
Tests assigning an attribute to a product variation type.
File
- modules/
product/ tests/ src/ Functional/ ProductAttributeTest.php, line 100
Class
- ProductAttributeTest
- Create, edit, delete, and change product attributes.
Namespace
Drupal\Tests\commerce_product\FunctionalCode
public function testProductVariationTypes() {
$this
->createEntity('commerce_product_attribute', [
'id' => 'color',
'label' => 'Color',
]);
$this
->drupalGet('admin/commerce/product-attributes/manage/color');
$edit = [
'variation_types[default]' => 'default',
'values[0][entity][name][0][value]' => 'Red',
];
$this
->submitForm($edit, t('Save'));
$this
->drupalGet('admin/commerce/config/product-variation-types/default/edit/fields');
$this
->assertSession()
->pageTextContains('attribute_color', 'The color attribute field has been created');
$this
->drupalGet('admin/commerce/product-attributes/manage/color');
$edit = [
'variation_types[default]' => FALSE,
];
$this
->submitForm($edit, t('Save'));
$this
->drupalGet('admin/commerce/config/product-variation-types/default/edit/fields');
$this
->assertSession()
->pageTextNotContains('attribute_color', 'The color attribute field has been deleted');
}