function PathBasedBreadcrumbBuilderTest::testBuildWithInvalidPath
Same name in other branches
- 11.x core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithInvalidPath()
Tests the build method with an invalid path.
@covers ::build @covers ::getRequestForPath
File
-
core/
modules/ system/ tests/ src/ Unit/ Breadcrumbs/ PathBasedBreadcrumbBuilderTest.php, line 345
Class
- PathBasedBreadcrumbBuilderTest
- @coversDefaultClass \Drupal\system\PathBasedBreadcrumbBuilder @group system
Namespace
Drupal\Tests\system\Unit\BreadcrumbsCode
public function testBuildWithInvalidPath() : void {
// The parse_url() function returns FALSE for '/:123/foo' so the
// Request::create() method therefore considers it to be an invalid URI.
$this->context
->expects($this->once())
->method('getPathInfo')
->willReturn('/:123/foo/bar');
$breadcrumb = $this->builder
->build($this->createMock('Drupal\\Core\\Routing\\RouteMatchInterface'));
// No path matched, though at least the frontpage is displayed.
$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.