public function AttributeTest::testAttributeUiClassAttributeOverview in Ubercart 8.4
Tests the product class attribute user interface.
File
- uc_attribute/
tests/ src/ Functional/ AttributeTest.php, line 580
Class
- AttributeTest
- Tests the product attribute API.
Namespace
Drupal\Tests\uc_attribute\FunctionalCode
public function testAttributeUiClassAttributeOverview() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$class = $this
->createProductClass();
$attribute = $this
->createAttribute();
$this
->drupalGet('admin/structure/types/manage/' . $class
->id() . '/attributes');
$assert
->pageTextContains('No attributes available.');
uc_attribute_subject_save($attribute, 'class', $class
->id());
$this
->drupalGet('admin/structure/types/manage/' . $class
->id() . '/attributes');
$assert
->pageTextNotContains('No attributes available.');
$a = (array) $this
->createAttribute([], FALSE);
unset($a['name'], $a['description']);
foreach ($a as $field => $value) {
$edit["attributes[{$attribute->aid}][{$field}]"] = $value;
}
$this
->showVar($edit);
$this
->drupalGet('admin/structure/types/manage/' . $class
->id() . '/attributes');
$this
->submitForm($edit, 'Save changes');
$attribute = uc_attribute_load($attribute->aid, $class
->id(), 'class');
$fields_ok = TRUE;
foreach ($a as $field => $value) {
if ($attribute->{$field} != $value) {
$this
->showVar($attribute);
$this
->showVar($a);
$fields_ok = FALSE;
break;
}
}
$this
->assertTrue($fields_ok, 'Class attribute edited successfully by form.');
$edit = [];
$edit["attributes[{$attribute->aid}][remove]"] = TRUE;
$this
->drupalGet('admin/structure/types/manage/' . $class
->id() . '/attributes');
$this
->submitForm($edit, 'Save changes');
$assert
->pageTextContains('No attributes available.');
}