public function AttributeTest::testAttributeUiProductAttributes in Ubercart 8.4
Tests the "product attributes" page.
File
- uc_attribute/
tests/ src/ Functional/ AttributeTest.php, line 694
Class
- AttributeTest
- Tests the product attribute API.
Namespace
Drupal\Tests\uc_attribute\FunctionalCode
public function testAttributeUiProductAttributes() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$product = $this
->createProduct();
$attribute = $this
->createAttribute([
'display' => 1,
]);
$option = $this
->createAttributeOption([
'aid' => $attribute->aid,
]);
$this
->drupalGet('node/' . $product
->id() . '/edit/attributes');
$assert
->pageTextContains('No attributes available.');
$this
->clickLink('Add existing attribute');
$assert
->pageTextContains($attribute->name);
$this
->submitForm([
'add_attributes[' . $attribute->aid . ']' => 1,
], 'Add attributes');
$assert
->pageTextContains('1 attribute has been added.');
// Check for attribute name.
$assert
->pageTextContains($attribute->name);
// Check for attribute label.
$assert
->fieldValueEquals('attributes[' . $attribute->aid . '][label]', $attribute->label);
// Check for default option name.
$assert
->pageTextContains($option->name);
// Check for default option price.
$assert
->pageTextContains(uc_currency_format($option->price));
// Check for attribute display setting.
$assert
->fieldValueEquals('attributes[' . $attribute->aid . '][display]', $attribute->display);
$this
->drupalGet('node/' . $product
->id() . '/edit/attributes/add');
$assert
->pageTextNotContains($attribute->name);
$assert
->pageTextContains('No attributes left to add.');
$edit = [
'attributes[' . $attribute->aid . '][remove]' => 1,
];
$this
->drupalGet('node/' . $product
->id() . '/edit/attributes');
$this
->submitForm($edit, 'Save changes');
$assert
->pageTextContains('No attributes available.');
}