function LayoutBuilderTest::testRemovingSectionWithoutLayoutLabel

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

Tests removing section without layout label configuration.

File

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

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testRemovingSectionWithoutLayoutLabel() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $this->drupalLogin($this->drupalCreateUser([
        'configure any layout',
        'administer node display',
    ]));
    // Enable overrides.
    $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
    $this->drupalGet("{$field_ui_prefix}/display/default");
    $this->submitForm([
        'layout[enabled]' => TRUE,
    ], 'Save');
    $this->submitForm([
        'layout[allow_custom]' => TRUE,
    ], 'Save');
    $this->drupalGet("{$field_ui_prefix}/display/default/layout");
    $page->clickLink('Add section');
    $assert_session->linkExists('Layout Without Label');
    $page->clickLink('Layout Without Label');
    $page->pressButton('Add section');
    $assert_session->elementsCount('css', '.layout', 2);
    $assert_session->linkExists('Remove Section 1');
    $this->clickLink('Remove Section 1');
    $page->pressButton('Remove');
    $assert_session->statusCodeEquals(200);
    $assert_session->elementsCount('css', '.layout', 1);
}

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