function LayoutBuilderTest::testBreadcrumb

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

Tests the expected breadcrumbs of the Layout Builder UI.

File

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

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testBreadcrumb() {
    $page = $this->getSession()
        ->getPage();
    $this->drupalPlaceBlock('system_breadcrumb_block');
    $this->drupalLogin($this->drupalCreateUser([
        'configure any layout',
        'administer node display',
        'administer content types',
        'access administration pages',
    ]));
    // From the manage display page, go to manage the layout.
    $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
    $this->drupalPostForm(NULL, [
        'layout[enabled]' => TRUE,
    ], 'Save');
    $this->drupalPostForm(NULL, [
        'layout[allow_custom]' => TRUE,
    ], 'Save');
    $page->clickLink('Manage layout');
    $breadcrumb_titles = [];
    foreach ($page->findAll('css', '.breadcrumb a') as $link) {
        $breadcrumb_titles[$link->getText()] = $link->getAttribute('href');
    }
    $base_path = base_path();
    $expected = [
        'Home' => $base_path,
        'Administration' => $base_path . 'admin',
        'Structure' => $base_path . 'admin/structure',
        'Content types' => $base_path . 'admin/structure/types',
        'Bundle with section field' => $base_path . 'admin/structure/types/manage/bundle_with_section_field',
        'Manage display' => $base_path . 'admin/structure/types/manage/bundle_with_section_field/display/default',
    ];
    $this->assertSame($expected, $breadcrumb_titles);
}

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