X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd6%2FMigrateDateFormatTest.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd6%2FMigrateDateFormatTest.php;h=b45a36050f0d6765eac4651159b297b92e417ceb;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php new file mode 100644 index 000000000..b45a36050 --- /dev/null +++ b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php @@ -0,0 +1,56 @@ +executeMigration('d6_date_formats'); + } + + /** + * Tests the Drupal 6 date formats to Drupal 8 migration. + */ + public function testDateFormats() { + $short_date_format = DateFormat::load('short'); + $this->assertIdentical('\S\H\O\R\T m/d/Y - H:i', $short_date_format->getPattern()); + + $medium_date_format = DateFormat::load('medium'); + $this->assertIdentical('\M\E\D\I\U\M D, m/d/Y - H:i', $medium_date_format->getPattern()); + + $long_date_format = DateFormat::load('long'); + $this->assertIdentical('\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->assertIdentical('\S\H\O\R\T d/m/Y - H:i', $short_date_format->getPattern()); + + } + +}