public function AttributeTest::testAttributeUiClassAttributeOptionOverview in Ubercart 8.4
Tests the product class attribute option user interface.
File
- uc_attribute/
tests/ src/ Functional/ AttributeTest.php, line 649
Class
- AttributeTest
- Tests the product attribute API.
Namespace
Drupal\Tests\uc_attribute\FunctionalCode
public function testAttributeUiClassAttributeOptionOverview() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$class = $this
->createProductClass();
$attribute = $this
->createAttribute();
$option = $this
->createAttributeOption([
'aid' => $attribute->aid,
]);
uc_attribute_subject_save($attribute, 'class', $class
->id());
$this
->drupalGet('admin/structure/types/manage/' . $class
->id() . '/options');
// Verify class attribute option form is working.
$assert
->responseContains($option->name . '</label>');
$o = (array) $this
->createAttributeOption([
'aid' => $attribute->aid,
], FALSE);
unset($o['name'], $o['aid']);
$o['select'] = TRUE;
foreach ($o as $field => $value) {
$edit["attributes[{$attribute->aid}][options][{$option->oid}][{$field}]"] = $value;
}
unset($o['select']);
$edit["attributes[{$attribute->aid}][default]"] = $option->oid;
$this
->showVar($edit);
$this
->drupalGet('admin/structure/types/manage/' . $class
->id() . '/options');
$this
->submitForm($edit, 'Save changes');
$assert
->pageTextContains('The changes have been saved.');
$this
->showVar($option);
$option = uc_attribute_subject_option_load($option->oid, 'class', $class
->id());
$fields_ok = TRUE;
foreach ($o as $field => $value) {
if ($option->{$field} != $value) {
$this
->showVar($option);
$this
->showVar($o);
$fields_ok = FALSE;
break;
}
}
$this
->assertTrue($fields_ok, 'Class attribute option edited successfully by form.');
}