You are here

public function MigrateFieldTest::testDatetimeFields in Drupal 10

Tests migrating D7 datetime fields.

File

core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php, line 197

Class

MigrateFieldTest
Migrates Drupal 7 fields.

Namespace

Drupal\Tests\field\Kernel\Migrate\d7

Code

public function testDatetimeFields() {
  $this
    ->installConfig(static::$modules);
  $this
    ->executeMigration('d7_field');

  // Datetime field with 'todate' settings is not migrated.
  $this
    ->assertNull(FieldStorageConfig::load('node.field_event'));

  // Check that we've reported on a conflict in widget_types.
  // Validate that the source count and processed count match up.

  /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
  $migration = $this
    ->getMigration('d7_field');
  $messages = iterator_to_array($migration
    ->getIdMap()
    ->getMessages());
  $this
    ->assertCount(5, $messages);
  $msg = "d7_field:type:process_field: Can't migrate field 'field_event' with 'todate' settings. Enable the datetime_range module. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#datetime";
  $this
    ->assertSame($messages[4]->message, $msg);
}