function TitleClosureTest::testRepeatedAttributesHaveOwnTitles
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/Core/Routing/TitleClosureTest.php \Drupal\KernelTests\Core\Routing\TitleClosureTest::testRepeatedAttributesHaveOwnTitles()
Tests that repeated attributes on one method keep their own closures.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Routing/ TitleClosureTest.php, line 57
Class
- TitleClosureTest
- Tests title closures declared on Route attributes.
Namespace
Drupal\KernelTests\Core\RoutingCode
public function testRepeatedAttributesHaveOwnTitles() : void {
$route = $this->container
->get('router.route_provider')
->getRouteByName('router_test.title_closure_other');
// The second attribute on the method is recorded at index 1.
$this->assertSame([
TestAttributes::class,
'titleClosure',
1,
], $route->getDefault('_title_closure'));
$request = new Request();
$request->attributes
->set('parameter', 'test');
$title = $this->container
->get('title_resolver')
->getTitle($request, $route);
$this->assertSame('Second title for test', (string) $title);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.