public function PathBasedBreadcrumbBuilderTest::testBuildWithUserPath in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithUserPath()
Tests the breadcrumb for a user path.
@covers ::build @covers ::getRequestForPath
File
- core/
modules/ system/ tests/ src/ Unit/ Breadcrumbs/ PathBasedBreadcrumbBuilderTest.php, line 357 - Contains \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest.
Class
- PathBasedBreadcrumbBuilderTest
- @coversDefaultClass \Drupal\system\PathBasedBreadcrumbBuilder @group system
Namespace
Drupal\Tests\system\Unit\BreadcrumbsCode
public function testBuildWithUserPath() {
$this->context
->expects($this
->once())
->method('getPathInfo')
->will($this
->returnValue('/user/1/edit'));
$this
->setupStubPathProcessor();
$route_1 = new Route('/user/1');
$this->requestMatcher
->expects($this
->exactly(1))
->method('matchRequest')
->will($this
->returnCallback(function (Request $request) use ($route_1) {
if ($request
->getPathInfo() == '/user/1') {
return [
RouteObjectInterface::ROUTE_NAME => 'user_page',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
'_raw_variables' => new ParameterBag([]),
];
}
}));
$this
->setupAccessManagerToAllow();
$this->titleResolver
->expects($this
->once())
->method('getTitle')
->with($this
->anything(), $route_1)
->will($this
->returnValue('Admin'));
$breadcrumb = $this->builder
->build($this
->createMock('Drupal\\Core\\Routing\\RouteMatchInterface'));
$this
->assertEquals([
0 => new Link('Home', new Url('<front>')),
1 => new Link('Admin', new Url('user_page')),
], $breadcrumb
->getLinks());
$this
->assertEquals([
'url.path.is_front',
'url.path.parent',
'user.permissions',
], $breadcrumb
->getCacheContexts());
$this
->assertEquals([], $breadcrumb
->getCacheTags());
$this
->assertEquals(Cache::PERMANENT, $breadcrumb
->getCacheMaxAge());
}