function TitleResolverTest::testStaticTitleWithParameter
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php \Drupal\Tests\Core\Controller\TitleResolverTest::testStaticTitleWithParameter()
- 8.9.x core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php \Drupal\Tests\Core\Controller\TitleResolverTest::testStaticTitleWithParameter()
- 10 core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php \Drupal\Tests\Core\Controller\TitleResolverTest::testStaticTitleWithParameter()
Tests a static title with a parameter.
See also
\Drupal\Core\Controller\TitleResolver::getTitle()
File
-
core/
tests/ Drupal/ Tests/ Core/ Controller/ TitleResolverTest.php, line 99
Class
- TitleResolverTest
- @coversDefaultClass \Drupal\Core\Controller\TitleResolver @group Controller
Namespace
Drupal\Tests\Core\ControllerCode
public function testStaticTitleWithParameter() : void {
$raw_variables = new InputBag([
'test' => 'value',
'test2' => 'value2',
]);
$request = new Request();
$request->attributes
->set('_raw_variables', $raw_variables);
$route = new Route('/test-route', [
'_title' => 'static title @test',
]);
$this->assertEquals(new TranslatableMarkup('static title @test', [
'@test' => 'value',
'%test' => 'value',
'@test2' => 'value2',
'%test2' => 'value2',
], [], $this->translationManager), $this->titleResolver
->getTitle($request, $route));
$route = new Route('/test-route', [
'_title' => 'static title %test',
]);
$this->assertEquals(new TranslatableMarkup('static title %test', [
'@test' => 'value',
'%test' => 'value',
'@test2' => 'value2',
'%test2' => 'value2',
], [], $this->translationManager), $this->titleResolver
->getTitle($request, $route));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.