function TranslationStringTest::rebootAndPrepareSettings

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php \Drupal\KernelTests\Core\StringTranslation\TranslationStringTest::rebootAndPrepareSettings()
  2. 10 core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php \Drupal\KernelTests\Core\StringTranslation\TranslationStringTest::rebootAndPrepareSettings()
  3. 11.x core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php \Drupal\KernelTests\Core\StringTranslation\TranslationStringTest::rebootAndPrepareSettings()

Reboots the kernel to set custom translations in Settings.

1 call to TranslationStringTest::rebootAndPrepareSettings()
TranslationStringTest::testComparison in core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php
Tests that TranslatableMarkup objects can be compared.

File

core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php, line 57

Class

TranslationStringTest
Tests the TranslatableMarkup class.

Namespace

Drupal\KernelTests\Core\StringTranslation

Code

protected function rebootAndPrepareSettings() {
    // Reboot the container so that different services are injected and the new
    // settings are picked.
    $kernel = $this->container
        ->get('kernel');
    $kernel->shutdown();
    $kernel->boot();
    $settings = Settings::getAll();
    $settings['locale_custom_strings_de'] = [
        '' => [
            'Example @number' => 'Example @number translated',
        ],
    ];
    // Recreate the settings static.
    new Settings($settings);
}

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