function MigrateDateFormatTest::testDateFormats

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php \Drupal\Tests\system\Kernel\Migrate\d6\MigrateDateFormatTest::testDateFormats()
  2. 8.9.x core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php \Drupal\Tests\system\Kernel\Migrate\d6\MigrateDateFormatTest::testDateFormats()
  3. 10 core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php \Drupal\Tests\system\Kernel\Migrate\d6\MigrateDateFormatTest::testDateFormats()

Tests the Drupal 6 date formats to Drupal 8 migration.

File

core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php, line 29

Class

MigrateDateFormatTest
Upgrade date formats to core.date_format.*.yml.

Namespace

Drupal\Tests\system\Kernel\Migrate\d6

Code

public function testDateFormats() : void {
    $short_date_format = DateFormat::load('short');
    $this->assertSame('\\S\\H\\O\\R\\T m/d/Y - H:i', $short_date_format->getPattern());
    $medium_date_format = DateFormat::load('medium');
    $this->assertSame('\\M\\E\\D\\I\\U\\M D, m/d/Y - H:i', $medium_date_format->getPattern());
    $long_date_format = DateFormat::load('long');
    $this->assertSame('\\L\\O\\N\\G l, F j, Y - H:i', $long_date_format->getPattern());
    // Test that we can re-import using the EntityDateFormat destination.
    Database::getConnection('default', 'migrate')->update('variable')
        ->fields([
        'value' => serialize('\\S\\H\\O\\R\\T d/m/Y - H:i'),
    ])
        ->condition('name', 'date_format_short')
        ->execute();
    $migration = $this->getMigration('d6_date_formats');
    \Drupal::database()->truncate($migration->getIdMap()
        ->mapTableName())
        ->execute();
    $this->executeMigration($migration);
    $short_date_format = DateFormat::load('short');
    $this->assertSame('\\S\\H\\O\\R\\T d/m/Y - H:i', $short_date_format->getPattern());
}

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