You are here

protected function AssertBreadcrumbTrait::assertBreadcrumb in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php \Drupal\system\Tests\Menu\AssertBreadcrumbTrait::assertBreadcrumb()

Assert that a given path shows certain breadcrumb links.

Parameters

\Drupal\Core\Url|string $goto: (optional) A path or URL to pass to Drupal\simpletest\WebTestBase::drupalGet().

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\simpletest\WebTestBase::assertTitle(). 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).

2 calls to AssertBreadcrumbTrait::assertBreadcrumb()
BreadcrumbTest::testBreadCrumbs in core/modules/system/src/Tests/Menu/BreadcrumbTest.php
Tests breadcrumbs on node and administrative paths.
TermTranslationBreadcrumbTest::testTranslatedBreadcrumbs in core/modules/taxonomy/src/Tests/TermTranslationBreadcrumbTest.php
Test translated breadcrumbs.

File

core/modules/system/src/Tests/Menu/AssertBreadcrumbTrait.php, line 40
Contains \Drupal\system\Tests\Menu\AssertBreadcrumbTrait.

Class

AssertBreadcrumbTrait
Provides test assertions for verifying breadcrumbs.

Namespace

Drupal\system\Tests\Menu

Code

protected function assertBreadcrumb($goto, array $trail, $page_title = NULL, array $tree = array(), $last_active = TRUE) {
  if (isset($goto)) {
    $this
      ->drupalGet($goto);
  }
  $this
    ->assertBreadcrumbParts($trail);

  // Additionally assert page title, if given.
  if (isset($page_title)) {
    $this
      ->assertTitle(strtr('@title | Drupal', array(
      '@title' => $page_title,
    )));
  }

  // Additionally assert active trail in a menu tree output, if given.
  if ($tree) {
    $this
      ->assertMenuActiveTrail($tree, $last_active);
  }
}