function LayoutBuilderTest::testSimpleConfigBasedLayout

Same name and namespace in other branches
  1. 8.9.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testSimpleConfigBasedLayout()
  2. 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testSimpleConfigBasedLayout()
  3. 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testSimpleConfigBasedLayout()

Tests a config-based implementation of Layout Builder.

See also

\Drupal\layout_builder_test\Plugin\SectionStorage\SimpleConfigSectionStorage

File

core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php, line 1408

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testSimpleConfigBasedLayout() {
    $assert_session = $this->assertSession();
    $this->drupalLogin($this->createUser([
        'configure any layout',
    ]));
    // Prepare an object with a pre-existing section.
    $this->container
        ->get('config.factory')
        ->getEditable('layout_builder_test.test_simple_config.existing')
        ->set('sections', [
        (new Section('layout_twocol'))->toArray(),
    ])
        ->save();
    // The pre-existing section is found.
    $this->drupalGet('layout-builder-test-simple-config/existing');
    $assert_session->elementsCount('css', '.layout', 1);
    $assert_session->elementsCount('css', '.layout--twocol', 1);
    // No layout is selected for a new object.
    $this->drupalGet('layout-builder-test-simple-config/new');
    $assert_session->elementNotExists('css', '.layout');
}

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