function TranslationStringTest::rebootAndPrepareSettings

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php \Drupal\KernelTests\Core\StringTranslation\TranslationStringTest::rebootAndPrepareSettings()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/StringTranslation/TranslationStringTest.php \Drupal\KernelTests\Core\StringTranslation\TranslationStringTest::rebootAndPrepareSettings()
  3. 10 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 59

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');
    // @todo This used to call shutdown() and boot(). rebuildContainer() is
    // needed until we stop pushing the request twice and only popping it once.
    // @see https://www.drupal.org/i/2613044
    $kernel->rebuildContainer();
    $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.