function ModerationStateTestBase::enableModerationThroughUi

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php \Drupal\Tests\content_moderation\Functional\ModerationStateTestBase::enableModerationThroughUi()
  2. 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php \Drupal\Tests\content_moderation\Functional\ModerationStateTestBase::enableModerationThroughUi()
  3. 10 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 139

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->assertSession()
        ->linkByHrefExists('admin/config/workflow/workflows/manage/' . $workflow_id);
    $edit['bundles[' . $content_type_id . ']'] = TRUE;
    $this->drupalGet('admin/config/workflow/workflows/manage/' . $workflow_id . '/type/node');
    $this->submitForm($edit, '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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.