You are here

public function LayoutBuilderTest::testBreadcrumb in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testBreadcrumb()
  2. 9 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 1323

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
    ->submitForm([
    'layout[enabled]' => TRUE,
  ], 'Save');
  $this
    ->submitForm([
    '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',
    'External link' => 'http://www.example.com',
  ];
  $this
    ->assertSame($expected, $breadcrumb_titles);
}