function LayoutBuilderContentModerationIntegrationTest::setUp

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php \Drupal\Tests\content_moderation\Functional\LayoutBuilderContentModerationIntegrationTest::setUp()
  2. 8.9.x core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php \Drupal\Tests\content_moderation\Functional\LayoutBuilderContentModerationIntegrationTest::setUp()
  3. 11.x core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php \Drupal\Tests\content_moderation\Functional\LayoutBuilderContentModerationIntegrationTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/content_moderation/tests/src/Functional/LayoutBuilderContentModerationIntegrationTest.php, line 41

Class

LayoutBuilderContentModerationIntegrationTest
Tests Content Moderation's integration with Layout Builder.

Namespace

Drupal\Tests\content_moderation\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // @todo The Layout Builder UI relies on local tasks; fix in
    //   https://www.drupal.org/project/drupal/issues/2917777.
    $this->drupalPlaceBlock('local_tasks_block');
    // Add a new bundle.
    $this->createContentType([
        'type' => 'bundle_with_section_field',
    ]);
    // Add a new block content bundle to the editorial workflow.
    BlockContentType::create([
        'id' => 'basic',
        'label' => 'Basic',
        'revision' => 1,
    ])->save();
    block_content_add_body_field('basic');
    // Enable layout overrides.
    LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')->enableLayoutBuilder()
        ->setOverridable()
        ->save();
    // Create a node before enabling the workflow on the bundle.
    $node = $this->createNode([
        'type' => 'bundle_with_section_field',
        'title' => 'Pre-workflow node',
        'body' => [
            [
                'value' => 'The first node body',
            ],
        ],
    ]);
    // View the node to ensure the new extra field blocks are not cached when
    // the workflow is updated.
    $this->drupalGet($node->toUrl());
    // Add editorial workflow for the bundle.
    $workflow = $this->createEditorialWorkflow();
    $workflow->getTypePlugin()
        ->addEntityTypeAndBundle('block_content', 'basic');
    $workflow->getTypePlugin()
        ->addEntityTypeAndBundle('node', 'bundle_with_section_field');
    $workflow->save();
    $this->drupalLogin($this->drupalCreateUser([
        'configure any layout',
        'edit any bundle_with_section_field content',
        'view bundle_with_section_field revisions',
        'revert bundle_with_section_field revisions',
        'view own unpublished content',
        'view latest version',
        'use editorial transition create_new_draft',
        'use editorial transition publish',
        'create and edit custom blocks',
    ]));
}

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