function TitleResolverTest::testStaticTitleWithNullAndArrayValueParameter
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php \Drupal\Tests\Core\Controller\TitleResolverTest::testStaticTitleWithNullAndArrayValueParameter()
- 10 core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php \Drupal\Tests\Core\Controller\TitleResolverTest::testStaticTitleWithNullAndArrayValueParameter()
Tests a static title with a non-scalar value parameter.
See also
\Drupal\Core\Controller\TitleResolver::getTitle()
File
-
core/
tests/ Drupal/ Tests/ Core/ Controller/ TitleResolverTest.php, line 116
Class
- TitleResolverTest
- @coversDefaultClass \Drupal\Core\Controller\TitleResolver @group Controller
Namespace
Drupal\Tests\Core\ControllerCode
public function testStaticTitleWithNullAndArrayValueParameter() : void {
$raw_variables = new InputBag([
'test1' => NULL,
'test2' => [
'foo' => 'bar',
],
'test3' => 'value',
]);
$request = new Request();
$request->attributes
->set('_raw_variables', $raw_variables);
$route = new Route('/test-route', [
'_title' => 'static title %test1 @test1 %test2 @test2 %test3 @test3',
]);
$translatable_markup = $this->titleResolver
->getTitle($request, $route);
$arguments = $translatable_markup->getArguments();
$this->assertNotContains('@test1', $arguments);
$this->assertNotContains('%test1', $arguments);
$this->assertNotContains('@test2', $arguments);
$this->assertNotContains('%test2', $arguments);
$this->assertSame('value', $translatable_markup->getArguments()['@test3']);
$this->assertSame('value', $translatable_markup->getArguments()['%test3']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.