function LayoutBuilderTest::testLayoutBuilderChooseBlocksAlter

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testLayoutBuilderChooseBlocksAlter()

File

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

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testLayoutBuilderChooseBlocksAlter() {
    // See layout_builder_test_plugin_filter_block__layout_builder_alter().
    $assert_session = $this->assertSession();
    $this->drupalLogin($this->drupalCreateUser([
        'configure any layout',
        'administer node display',
        'administer node fields',
    ]));
    // From the manage display page, go to manage the layout.
    $this->drupalPostForm('admin/structure/types/manage/bundle_with_section_field/display/default', [
        'layout[enabled]' => TRUE,
    ], 'Save');
    $assert_session->linkExists('Manage layout');
    $this->clickLink('Manage layout');
    // Add a new block.
    $this->clickLink('Add block');
    // Verify that blocks not modified are present.
    $assert_session->linkExists('Powered by Drupal');
    $assert_session->linkExists('Default revision');
    // Verify that blocks explicitly removed are not present.
    $assert_session->linkNotExists('Help');
    $assert_session->linkNotExists('Sticky at top of lists');
    $assert_session->linkNotExists('Page title');
    // Verify that Changed block is not present on first section.
    $assert_session->linkNotExists('Changed');
    // Go back to Manage layout.
    $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
    $this->clickLink('Manage layout');
    // Add a new section.
    $this->clickLink('Add section', 1);
    $assert_session->linkExists('Two column');
    $this->clickLink('Two column');
    $assert_session->buttonExists('Add section');
    $this->getSession()
        ->getPage()
        ->pressButton('Add section');
    // Add a new block to second section.
    $this->clickLink('Add block', 1);
    // Verify that Changed block is present on second section.
    $assert_session->linkExists('Changed');
}

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