public function AttributeTest::testAttributeUiAttributeOptionsAdd in Ubercart 8.4
Tests the "add attribute option" user interface.
File
- uc_attribute/
tests/ src/ Functional/ AttributeTest.php, line 491
Class
- AttributeTest
- Tests the product attribute API.
Namespace
Drupal\Tests\uc_attribute\FunctionalCode
public function testAttributeUiAttributeOptionsAdd() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$attribute = $this
->createAttribute();
$this
->drupalGet('admin/store/products/attributes/' . $attribute->aid . '/options/add');
$assert
->pageTextContains('Options for ' . $attribute->name);
$edit = (array) $this
->createAttributeOption([
'aid' => $attribute->aid,
], FALSE);
unset($edit['aid']);
$this
->drupalGet('admin/store/products/attributes/' . $attribute->aid . '/options/add');
$this
->submitForm($edit, 'Submit');
$option = \Drupal::database()
->query('SELECT * FROM {uc_attribute_options} WHERE aid = :aid', [
':aid' => $attribute->aid,
])
->fetchObject();
$fields_ok = TRUE;
foreach ($edit as $field => $value) {
if ($option->{$field} != $value) {
$this
->showVar($option);
$this
->showVar($edit);
$fields_ok = FALSE;
break;
}
}
$this
->assertTrue($fields_ok, 'Attribute option added successfully by form.');
}