trait WorkbenchModerationTestTrait in Workbench Moderation 8
Defines a trait for common testing methods for workbench moderation.
Hierarchy
- trait \Drupal\Tests\workbench_moderation\Traits\WorkbenchModerationTestTrait
2 files declare their use of WorkbenchModerationTestTrait
- ModerationFormAccessTest.php in tests/
src/ Functional/ ModerationFormAccessTest.php - ModerationStateAccessTest.php in tests/
src/ Functional/ ModerationStateAccessTest.php
File
- tests/
src/ Traits/ WorkbenchModerationTestTrait.php, line 8
Namespace
Drupal\Tests\workbench_moderation\TraitsView source
trait WorkbenchModerationTestTrait {
/**
* Creates a new node type.
*
* @param string $label
* The human-readable label of the type to create.
* @param string $machine_name
* The machine name of the type to create.
*
* @return \Drupal\node\Entity\NodeType
* The node type just created.
*/
protected function createNodeType($label, $machine_name) {
/** @var \Drupal\node\Entity\NodeType $node_type */
$node_type = $this
->createContentType([
'name' => $label,
'type' => $machine_name,
]);
$node_type
->setThirdPartySetting('workbench_moderation', 'enabled', TRUE);
$node_type
->setThirdPartySetting('workbench_moderation', 'allowed_moderation_states', [
'draft',
'needs_review',
'published',
]);
$node_type
->save();
return $node_type;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WorkbenchModerationTestTrait:: |
protected | function | Creates a new node type. |