function DateFormatterTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Datetime/DateFormatterTest.php \Drupal\KernelTests\Core\Datetime\DateFormatterTest::setUp()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Datetime/DateFormatterTest.php \Drupal\KernelTests\Core\Datetime\DateFormatterTest::setUp()
  3. 10 core/tests/Drupal/KernelTests/Core/Datetime/DateFormatterTest.php \Drupal\KernelTests\Core\Datetime\DateFormatterTest::setUp()

Overrides KernelTestBase::setUp

File

core/tests/Drupal/KernelTests/Core/Datetime/DateFormatterTest.php, line 33

Class

DateFormatterTest
Tests date formatting.

Namespace

Drupal\KernelTests\Core\Datetime

Code

protected function setUp() : void {
    parent::setUp();
    $this->installConfig([
        'system',
    ]);
    $this->setSetting('locale_custom_strings_' . self::LANGCODE, [
        '' => [
            'Sunday' => 'domingo',
        ],
        'Long month name' => [
            'March' => 'marzo',
        ],
    ]);
    $formats = $this->container
        ->get('entity_type.manager')
        ->getStorage('date_format')
        ->loadMultiple([
        'long',
        'medium',
        'short',
    ]);
    $formats['long']->setPattern('l, j. F Y - G:i')
        ->save();
    $formats['medium']->setPattern('j. F Y - G:i')
        ->save();
    $formats['short']->setPattern('Y M j - g:ia')
        ->save();
    ConfigurableLanguage::createFromLangcode(static::LANGCODE)->save();
}

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