function LayoutRestTestBase::setUp

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::setUp()
  2. 8.9.x core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::setUp()
  3. 11.x 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 50

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

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