function EnableLayoutBuilderTrait::enableLayoutBuilderFromUi

Same name in other branches
  1. 11.x core/modules/layout_builder/tests/src/Traits/EnableLayoutBuilderTrait.php \Drupal\Tests\layout_builder\Traits\EnableLayoutBuilderTrait::enableLayoutBuilderFromUi()

Enables Layout Builder using the UI.

Parameters

string $bundle: The bundle that Layout Builder is being enabled on.

string $viewMode: The view mode that Layout Builder is being enabled on.

bool $allowCustom: Whether custom layouts per entity should be allowed.

2 calls to EnableLayoutBuilderTrait::enableLayoutBuilderFromUi()
LayoutBuilderViewModeTest::testNonDefaultViewMode in core/modules/layout_builder/tests/src/Functional/LayoutBuilderViewModeTest.php
Tests that a non-default view mode works as expected.
LayoutDisplayTest::testMultipleViewModes in core/modules/layout_builder/tests/src/Functional/LayoutDisplayTest.php
Tests the interaction between multiple view modes.

File

core/modules/layout_builder/tests/src/Traits/EnableLayoutBuilderTrait.php, line 37

Class

EnableLayoutBuilderTrait
Test trait to enable or disable Layout Builder on an entity view display.

Namespace

Drupal\Tests\layout_builder\Traits

Code

protected function enableLayoutBuilderFromUi(string $bundle, string $viewMode, bool $allowCustom = TRUE) : void {
    $path = sprintf('admin/structure/types/manage/%s/display/%s', $bundle, $viewMode);
    $page = $this->getSession()
        ->getPage();
    $this->drupalGet($path);
    $page->checkField('layout[enabled]');
    $page->pressButton('Save');
    if ($allowCustom) {
        $page->checkField('layout[allow_custom]');
        $page->pressButton('Save');
    }
}

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