You are here

protected function LayoutRestTestBase::setUp in Drupal 10

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()
  2. 9 core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::setUp()

Overrides ResourceTestBase::setUp

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 48

Class

LayoutRestTestBase
Base class for Layout Builder REST tests.

Namespace

Drupal\Tests\layout_builder\Functional\Rest

Code

protected function setUp() : void {
  parent::setUp();
  $assert_session = $this
    ->assertSession();
  $this
    ->createContentType([
    'type' => 'bundle_with_section_field',
  ]);
  LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
    ->enableLayoutBuilder()
    ->setOverridable()
    ->save();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'configure any layout',
    'bypass node access',
    'create bundle_with_section_field content',
    'edit any bundle_with_section_field content',
  ]));
  $page = $this
    ->getSession()
    ->getPage();

  // 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',
  ]);
}