function BreadcrumbFrontCacheContextsTest::testBreadcrumbsFrontPageCache

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php \Drupal\Tests\system\Functional\Menu\BreadcrumbFrontCacheContextsTest::testBreadcrumbsFrontPageCache()
  2. 10 core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php \Drupal\Tests\system\Functional\Menu\BreadcrumbFrontCacheContextsTest::testBreadcrumbsFrontPageCache()
  3. 11.x 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->assertTrue($crumbs[0]->getText() === 'Home');
}

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