function TwigMarkupInterfaceTest::testEmptyTranslation

Same name and namespace in other branches
  1. 9 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()
  3. 11.x 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 68

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.