You are here

protected function LayoutBuilderContentModerationIntegrationTest::setUp in Drupal 10

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

File

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

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');
  $workflow = $this
    ->createEditorialWorkflow();

  // Add a new bundle and add an editorial workflow.
  $this
    ->createContentType([
    'type' => 'bundle_with_section_field',
  ]);
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', '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');
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('block_content', 'basic');
  $workflow
    ->save();

  // Enable layout overrides.
  LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
    ->enableLayoutBuilder()
    ->setOverridable()
    ->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',
  ]));
}