trait CategoryCreationTrait in Mass Contact 8
Helper methods to create mass contact categories for testing.
Hierarchy
- trait \Drupal\Tests\mass_contact\Kernel\CategoryCreationTrait
2 files declare their use of CategoryCreationTrait
- MassContactCategoryTest.php in tests/
src/ Kernel/ Entity/ MassContactCategoryTest.php - MassContactTestBase.php in tests/
src/ Functional/ MassContactTestBase.php
File
- tests/
src/ Kernel/ CategoryCreationTrait.php, line 11
Namespace
Drupal\Tests\mass_contact\KernelView source
trait CategoryCreationTrait {
/**
* Creates a category.
*
* @return \Drupal\mass_contact\Entity\MassContactCategoryInterface
* The new category entity.
*/
public function createCategory(array $settings = []) {
$settings += [
'id' => mb_strtolower($this
->randomMachineName()),
'label' => $this
->randomString(),
'recipients' => [],
'selected' => FALSE,
];
$category = MassContactCategory::create($settings);
$category
->save();
return $category;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CategoryCreationTrait:: |
public | function | Creates a category. |