You are here

public function LayoutRestTestBase::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::setUp()

Overrides ResourceTestBase::setUp

1 call to LayoutRestTestBase::setUp()
OverrideSectionsTest::setUp in core/modules/layout_builder/tests/src/Functional/Rest/OverrideSectionsTest.php
1 method overrides LayoutRestTestBase::setUp()
OverrideSectionsTest::setUp in core/modules/layout_builder/tests/src/Functional/Rest/OverrideSectionsTest.php

File

core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php, line 46

Class

LayoutRestTestBase
Base class for Layout Builder REST tests.

Namespace

Drupal\Tests\layout_builder\Functional\Rest

Code

public function setUp() {
  parent::setUp();
  $assert_session = $this
    ->assertSession();
  $this
    ->createContentType([
    'type' => 'bundle_with_section_field',
  ]);
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'configure any layout',
    'administer node display',
    'administer display modes',
    'bypass node access',
    'create bundle_with_section_field content',
    'edit any bundle_with_section_field content',
  ]));
  $page = $this
    ->getSession()
    ->getPage();
  $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field/display';

  // Enable Layout Builder for the default view modes, and overrides.
  $this
    ->drupalGet("{$field_ui_prefix}/default");
  $page
    ->checkField('layout[enabled]');
  $page
    ->pressButton('Save');
  $page
    ->checkField('layout[allow_custom]');
  $page
    ->pressButton('Save');

  // Create a node.
  $this->node = $this
    ->createNode([
    'type' => 'bundle_with_section_field',
    'title' => 'A node at rest will stay at rest.',
  ]);
  $this
    ->drupalGet('node/' . $this->node
    ->id() . '/layout');
  $page
    ->clickLink('Add block');
  $page
    ->clickLink('Powered by Drupal');
  $page
    ->fillField('settings[label]', 'This is an override');
  $page
    ->checkField('settings[label_display]');
  $page
    ->pressButton('Add block');
  $page
    ->pressButton('Save layout');
  $assert_session
    ->pageTextContains('This is an override');
  $this->nodeStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('node');
  $this->node = $this->nodeStorage
    ->load($this->node
    ->id());
  $this
    ->drupalLogout();
  $this
    ->setUpAuthorization('ALL');
  $this
    ->provisionResource([
    static::$format,
  ], [
    'basic_auth',
  ]);
}