protected function ProductTestTrait::createProductClass in Ubercart 8.4
Creates a new product node type, AKA 'product class'.
@todo Fix this after adding a proper API call for saving a product class, so that we don't have to do this through the UI.
Parameters
array $data: (optional) An associative array with possible keys of 'type', 'name', and 'description' to initialize the product class.
Return value
\Drupal\node\Entity\NodeType Product class NodeType object.
6 calls to ProductTestTrait::createProductClass()
- AttributeTest::testAttributeApi in uc_attribute/
tests/ src/ Functional/ AttributeTest.php - Tests the basic attribute API.
- AttributeTest::testAttributeUiClassAttributeAdd in uc_attribute/
tests/ src/ Functional/ AttributeTest.php - Tests the "add product class attribute option" user interface.
- AttributeTest::testAttributeUiClassAttributeOptionOverview in uc_attribute/
tests/ src/ Functional/ AttributeTest.php - Tests the product class attribute option user interface.
- AttributeTest::testAttributeUiClassAttributeOverview in uc_attribute/
tests/ src/ Functional/ AttributeTest.php - Tests the product class attribute user interface.
- ProductRulesEventsTest::testRulesEvents in uc_product/
tests/ src/ Functional/ ProductRulesEventsTest.php - Tests the event provided by uc_product.
File
- uc_product/
tests/ src/ Traits/ ProductTestTrait.php, line 73
Class
- ProductTestTrait
- Utility functions to provide products for test purposes.
Namespace
Drupal\Tests\uc_product\TraitsCode
protected function createProductClass(array $data = []) {
$class = strtolower($this
->randomMachineName(12));
$edit = $data + [
'type' => $class,
'name' => $class,
'description' => $this
->randomMachineName(32),
'uc_product[product]' => TRUE,
];
$this
->drupalGet('admin/structure/types/add');
$this
->submitForm($edit, 'Save content type');
return NodeType::load($edit['type']);
}