public function PathBasedBreadcrumbBuilderTest::testBuildWithTwoPathElements in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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 173 - Contains \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest.
Class
- PathBasedBreadcrumbBuilderTest
- @coversDefaultClass \Drupal\system\PathBasedBreadcrumbBuilder @group system
Namespace
Drupal\Tests\system\Unit\BreadcrumbsCode
public function testBuildWithTwoPathElements() {
$this->context
->expects($this
->once())
->method('getPathInfo')
->will($this
->returnValue('/example/baz'));
$this
->setupStubPathProcessor();
$route_1 = new Route('/example');
$this->requestMatcher
->expects($this
->exactly(1))
->method('matchRequest')
->will($this
->returnCallback(function (Request $request) use ($route_1) {
if ($request
->getPathInfo() == '/example') {
return array(
RouteObjectInterface::ROUTE_NAME => 'example',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
'_raw_variables' => new ParameterBag(array()),
);
}
}));
$this
->setupAccessManagerToAllow();
$breadcrumb = $this->builder
->build($this
->getMock('Drupal\\Core\\Routing\\RouteMatchInterface'));
$this
->assertEquals([
0 => new Link('Home', new Url('<front>')),
1 => new Link('Example', new Url('example')),
], $breadcrumb
->getLinks());
$this
->assertEquals([
'url.path',
'user.permissions',
], $breadcrumb
->getCacheContexts());
$this
->assertEquals([], $breadcrumb
->getCacheTags());
$this
->assertEquals(Cache::PERMANENT, $breadcrumb
->getCacheMaxAge());
}