You are here

trait ContentModerationNotificationTestTrait in Content Moderation Notifications 8.3

Helper functions for testing workflow participants.

Hierarchy

1 file declares its use of ContentModerationNotificationTestTrait
CrudFormTest.php in tests/src/Functional/Form/CrudFormTest.php

File

tests/src/Kernel/ContentModerationNotificationTestTrait.php, line 11

Namespace

Drupal\Tests\content_moderation_notifications\Kernel
View source
trait ContentModerationNotificationTestTrait {
  use ContentModerationTestTrait;

  /**
   * Creates a page node type to test with, ensuring that it's moderated.
   *
   * @param string $entity_type
   *   The entity type ID to enable workflow for.
   * @param string $bundle
   *   The bundle ID.
   *
   * @return \Drupal\Core\Entity\EntityInterface|\Drupal\workflows\Entity\Workflow
   *   The 'editorial' workflow.
   */
  protected function enableModeration($entity_type = 'entity_test_rev', $bundle = 'entity_test_rev') {

    // Check if workflow has already been created.
    if (!($workflow = Workflow::load('editorial'))) {
      $workflow = $this
        ->createEditorialWorkflow();
    }
    $workflow
      ->getTypePlugin()
      ->addEntityTypeAndBundle($entity_type, $bundle);
    $workflow
      ->save();
    return $workflow;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentModerationNotificationTestTrait::enableModeration protected function Creates a page node type to test with, ensuring that it's moderated.
ContentModerationTestTrait::addEntityTypeAndBundleToWorkflow protected function Adds an entity type ID / bundle ID to the given workflow. 1
ContentModerationTestTrait::createEditorialWorkflow protected function Creates the editorial workflow. 1