You are here

public function TitleResolverTest::testStaticTitleWithNullValueParameter in Drupal 10

Tests a static title with a NULL value parameter.

See also

\Drupal\Core\Controller\TitleResolver::getTitle()

File

core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php, line 110
Contains \Drupal\Tests\Core\Controller\TitleResolverTest.

Class

TitleResolverTest
@coversDefaultClass \Drupal\Core\Controller\TitleResolver @group Controller

Namespace

Drupal\Tests\Core\Controller

Code

public function testStaticTitleWithNullValueParameter() {
  $raw_variables = new InputBag([
    'test' => NULL,
    'test2' => 'value',
  ]);
  $request = new Request();
  $request->attributes
    ->set('_raw_variables', $raw_variables);
  $route = new Route('/test-route', [
    '_title' => 'static title %test @test',
  ]);
  $translatable_markup = $this->titleResolver
    ->getTitle($request, $route);
  $this
    ->assertSame('', $translatable_markup
    ->getArguments()['@test']);
  $this
    ->assertSame('', $translatable_markup
    ->getArguments()['%test']);
  $this
    ->assertSame('value', $translatable_markup
    ->getArguments()['@test2']);
  $this
    ->assertSame('value', $translatable_markup
    ->getArguments()['%test2']);
}