You are here

protected function DateFormatterTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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 29

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