You are here

protected function WorkbenchModerationTestTrait::createNodeType in Workbench Moderation 8

Creates a new node type.

Parameters

string $label: The human-readable label of the type to create.

string $machine_name: The machine name of the type to create.

Return value

\Drupal\node\Entity\NodeType The node type just created.

2 calls to WorkbenchModerationTestTrait::createNodeType()
ModerationFormAccessTest::testModerationFormAccess in tests/src/Functional/ModerationFormAccessTest.php
Tests user access to the moderation form.
ModerationStateAccessTest::testViewShowsCorrectStates in tests/src/Functional/ModerationStateAccessTest.php
Test the view operation access handler with the view permission.

File

tests/src/Traits/WorkbenchModerationTestTrait.php, line 21

Class

WorkbenchModerationTestTrait
Defines a trait for common testing methods for workbench moderation.

Namespace

Drupal\Tests\workbench_moderation\Traits

Code

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;
}