function DateTimeTest::testDateFormatStorage

Test if the date formats are stored properly.

File

drupal/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php, line 123
Definition of Drupal\system\Tests\System\DateTimeTest.

Class

DateTimeTest
Tests generic date and time handling capabilities of Drupal.

Namespace

Drupal\system\Tests\System

Code

function testDateFormatStorage() {
  $date_format_info = array(
    'name' => 'testDateFormatStorage Short Format',
    'pattern' => array(
      'php' => 'dmYHis',
    ),
  );
  system_date_format_save('test_short', $date_format_info);
  $format = config('system.date')
    ->get('formats.test_short.pattern.php');
  $this
    ->assertEqual('dmYHis', $format, 'Unlocalized date format resides in general config.');
  $date_format_info['locales'] = array(
    'en',
  );
  system_date_format_save('test_short_en', $date_format_info);
  $format = config('system.date')
    ->get('formats.test_short_en.pattern.php');
  $this
    ->assertEqual('dmYHis', $format, 'Localized date format resides in general config too.');
  $format = config('locale.config.en.system.date')
    ->get('formats.test_short_en.pattern.php');
  $this
    ->assertEqual('dmYHis', $format, 'Localized date format resides in localized config.');
}