You are here

public function BreadcrumbFrontCacheContextsTest::testBreadcrumbsFrontPageCache in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php \Drupal\Tests\system\Functional\Menu\BreadcrumbFrontCacheContextsTest::testBreadcrumbsFrontPageCache()
  2. 9 core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php \Drupal\Tests\system\Functional\Menu\BreadcrumbFrontCacheContextsTest::testBreadcrumbsFrontPageCache()

Validate that breadcrumb markup get the right cache contexts.

Checking that the breadcrumb will be printed on node canonical routes even if it was rendered for the <front> page first.

File

core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php, line 80

Class

BreadcrumbFrontCacheContextsTest
Tests breadcrumbs functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

public function testBreadcrumbsFrontPageCache() {

  // Hit front page first as anonymous user with 'cold' render cache.
  $this
    ->drupalGet('<front>');
  $web_assert = $this
    ->assertSession();

  // Verify that no breadcrumb block presents.
  $web_assert
    ->elementNotExists('css', '.block-system-breadcrumb-block');

  // Verify that breadcrumb appears correctly for the test content
  // (which is not set as front page).
  $this
    ->drupalGet($this->nodeWithAlias->path->alias);
  $breadcrumbs = $this
    ->assertSession()
    ->elementExists('css', '.block-system-breadcrumb-block');
  $crumbs = $breadcrumbs
    ->findAll('css', 'ol li');
  $this
    ->assertCount(1, $crumbs);
  $this
    ->assertSame('Home', $crumbs[0]
    ->getText());
}