function AssertBreadcrumbTrait::assertBreadcrumb
Assert that a given path shows certain breadcrumb links.
Parameters
\Drupal\Core\Url|string|null $goto: (optional) A path or URL to pass to \Drupal\Tests\UiHelperTrait::drupalGet() otherwise a NULL value can be passed.
array $trail: An associative array whose keys are expected breadcrumb link paths and whose values are expected breadcrumb link texts (not sanitized).
string $page_title: (optional) A page title to additionally assert via \Drupal\Tests\WebAssert::titleEquals(). Without site name suffix.
array $tree: (optional) An associative array whose keys are link paths and whose values are link titles (not sanitized) of an expected active trail in a menu tree output on the page.
$last_active: (optional) Whether the last link in $tree is expected to be active (TRUE) or just to be in the active trail (FALSE).
string $active_trail_class: (optional) The class of the active trail. Defaults to 'menu-item--active-trail'.
string $active_class: (optional) The class of the active element. Defaults to 'is-active'.
11 calls to AssertBreadcrumbTrait::assertBreadcrumb()
- BlockContentTypeTest::testBlockContentTypeEditing in core/
modules/ block_content/ tests/ src/ Functional/ BlockContentTypeTest.php  - Tests editing a block type using the UI.
 - BreadcrumbTest::testAssertBreadcrumbTrait in core/
modules/ system/ tests/ src/ Functional/ Menu/ BreadcrumbTest.php  - Tests AssertBreadcrumbTrait works as expected.
 - BreadcrumbTest::testBreadCrumbs in core/
modules/ system/ tests/ src/ Functional/ Menu/ BreadcrumbTest.php  - Tests breadcrumbs on node and administrative paths.
 - DbLogTest::verifyBreadcrumbs in core/
modules/ dblog/ tests/ src/ Functional/ DbLogTest.php  - Generates and then verifies breadcrumbs.
 - HelpTopicTest::verifyBreadCrumb in core/
modules/ help/ tests/ src/ Functional/ HelpTopicTest.php  - Tests breadcrumb on a help topic page.
 
File
- 
              core/
modules/ system/ tests/ src/ Functional/ Menu/ AssertBreadcrumbTrait.php, line 43  
Class
- AssertBreadcrumbTrait
 - Provides test assertions for verifying breadcrumbs.
 
Namespace
Drupal\Tests\system\Functional\MenuCode
protected function assertBreadcrumb($goto, array $trail, $page_title = NULL, array $tree = [], $last_active = TRUE, $active_trail_class = 'menu-item--active-trail', $active_class = 'is-active') {
  if (isset($goto)) {
    $this->drupalGet($goto);
  }
  $this->assertBreadcrumbParts($trail);
  // Additionally assert page title, if given.
  if (isset($page_title)) {
    $this->assertSession()
      ->titleEquals("{$page_title} | Drupal");
  }
  // Additionally assert active trail in a menu tree output, if given.
  if ($tree) {
    $this->assertMenuActiveTrail($tree, $last_active, $active_trail_class, $active_class);
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.