function PathBasedBreadcrumbBuilderTest::testBuildWithTwoPathElements
Same name in other branches
- 9 core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithTwoPathElements()
- 8.9.x core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithTwoPathElements()
- 11.x core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithTwoPathElements()
Tests the build method with two path elements.
@covers ::build @covers ::getRequestForPath
File
-
core/
modules/ system/ tests/ src/ Unit/ Breadcrumbs/ PathBasedBreadcrumbBuilderTest.php, line 179
Class
- PathBasedBreadcrumbBuilderTest
- @coversDefaultClass \Drupal\system\PathBasedBreadcrumbBuilder @group system
Namespace
Drupal\Tests\system\Unit\BreadcrumbsCode
public function testBuildWithTwoPathElements() : void {
$this->context
->expects($this->once())
->method('getPathInfo')
->willReturn('/example/baz');
$this->setupStubPathProcessor();
$route_1 = new Route('/example');
$this->requestMatcher
->expects($this->exactly(1))
->method('matchRequest')
->willReturnCallback(function (Request $request) use ($route_1) {
if ($request->getPathInfo() == '/example') {
return [
RouteObjectInterface::ROUTE_NAME => 'example',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
'_raw_variables' => new InputBag([]),
];
}
});
$this->setupAccessManagerToAllow();
$breadcrumb = $this->builder
->build($this->createMock('Drupal\\Core\\Routing\\RouteMatchInterface'));
$this->assertEquals([
0 => new Link('Home', new Url('<front>')),
1 => new Link('Example', new Url('example')),
], $breadcrumb->getLinks());
$this->assertEqualsCanonicalizing([
'url.path.is_front',
'url.path.parent',
'user.permissions',
], $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.