function PathBasedBreadcrumbBuilderTest::testBuildWithOnePathElement

Same name in other branches
  1. 9 core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithOnePathElement()
  2. 8.9.x core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithOnePathElement()
  3. 11.x core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithOnePathElement()

Tests the build method with one path element.

@covers ::build

File

core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php, line 161

Class

PathBasedBreadcrumbBuilderTest
@coversDefaultClass \Drupal\system\PathBasedBreadcrumbBuilder @group system

Namespace

Drupal\Tests\system\Unit\Breadcrumbs

Code

public function testBuildWithOnePathElement() : void {
    $this->context
        ->expects($this->once())
        ->method('getPathInfo')
        ->willReturn('/example');
    $breadcrumb = $this->builder
        ->build($this->createMock('Drupal\\Core\\Routing\\RouteMatchInterface'));
    $this->assertEquals([
        0 => new Link('Home', new Url('<front>')),
    ], $breadcrumb->getLinks());
    $this->assertEqualsCanonicalizing([
        'url.path.is_front',
        'url.path.parent',
    ], $breadcrumb->getCacheContexts());
    $this->assertEqualsCanonicalizing([], $breadcrumb->getCacheTags());
    $this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}

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