You are here

public function ModerationStateTestBase::enableModerationThroughUi in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php \Drupal\Tests\content_moderation\Functional\ModerationStateTestBase::enableModerationThroughUi()

Enable moderation for a specified content type, using the UI.

Parameters

string $content_type_id: Machine name.

string $workflow_id: The workflow to attach to the bundle.

3 calls to ModerationStateTestBase::enableModerationThroughUi()
ModerationStateNodeTypeTest::testEnablingOnExistingContent in core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php
Tests enabling moderation on an existing node-type, with content.
ModerationStateTestBase::createContentTypeFromUi in core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php
Creates a content-type from the UI.
NodeAccessTest::testPageAccess in core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php
Verifies that a non-admin user can still access the appropriate pages.

File

core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php, line 137

Class

ModerationStateTestBase
Defines a base class for moderation state tests.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function enableModerationThroughUi($content_type_id, $workflow_id = 'editorial') {
  $this
    ->drupalGet('/admin/config/workflow/workflows');
  $this
    ->assertLinkByHref('admin/config/workflow/workflows/manage/' . $workflow_id);
  $edit['bundles[' . $content_type_id . ']'] = TRUE;
  $this
    ->drupalPostForm('admin/config/workflow/workflows/manage/' . $workflow_id . '/type/node', $edit, t('Save'));

  // Ensure the parent environment is up-to-date.
  // @see content_moderation_workflow_insert()
  \Drupal::service('entity_type.bundle.info')
    ->clearCachedBundles();
  \Drupal::service('entity_field.manager')
    ->clearCachedFieldDefinitions();

  /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
  $router_builder = $this->container
    ->get('router.builder');
  $router_builder
    ->rebuildIfNeeded();
}