You are here

public function TwigMarkupInterfaceTest::testEmptyTranslation in Zircon Profile 8

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

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

File

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

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));
}