You are here

public function TwigMarkupInterfaceTest::testEmptyTranslation in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php \Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest::testEmptyTranslation()
  2. 10 core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php \Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest::testEmptyTranslation()

Tests behavior if a string is translated to become an empty string.

File

core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php, line 67
Contains \Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest.

Class

TwigMarkupInterfaceTest
Tests Twig with MarkupInterface objects.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testEmptyTranslation() {
  $settings = Settings::getAll();
  $settings['locale_custom_strings_en'] = [
    '' => [
      'test' => '',
    ],
  ];

  // Recreate the settings static.
  new Settings($settings);
  $variable = new TranslatableMarkup('test');
  $this
    ->assertEquals('', $this
    ->renderObjectWithTwig($variable));
  $variable = new TranslatableMarkup('test', [], [
    'langcode' => 'de',
  ]);
  $this
    ->assertEquals('<span>test</span>', $this
    ->renderObjectWithTwig($variable));
}