function PathBasedBreadcrumbBuilderTest::testBuildWithException
Same name in other branches
- 9 core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithException()
- 8.9.x core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithException()
- 10 core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithException()
Tests that exceptions during request matching are caught.
@covers ::build @covers ::getRequestForPath
@dataProvider providerTestBuildWithException
File
-
core/
modules/ system/ tests/ src/ Unit/ Breadcrumbs/ PathBasedBreadcrumbBuilderTest.php, line 276
Class
- PathBasedBreadcrumbBuilderTest
- @coversDefaultClass \Drupal\system\PathBasedBreadcrumbBuilder @group system
Namespace
Drupal\Tests\system\Unit\BreadcrumbsCode
public function testBuildWithException($exception_class, $exception_argument) : void {
$this->context
->expects($this->once())
->method('getPathInfo')
->willReturn('/example/bar');
$this->setupStubPathProcessor();
$this->requestMatcher
->expects($this->any())
->method('matchRequest')
->will($this->throwException(new $exception_class($exception_argument)));
$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.