You are here

public function MigrateFieldPluginManagerTest::testPluginSelection in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/tests/src/Kernel/MigrateFieldPluginManagerTest.php \Drupal\Tests\migrate_drupal\Kernel\MigrateFieldPluginManagerTest::testPluginSelection()

Tests that the correct MigrateField plugins are used.

@covers ::getPluginIdFromFieldType

File

core/modules/migrate_drupal/tests/src/Kernel/MigrateFieldPluginManagerTest.php, line 52

Class

MigrateFieldPluginManagerTest
Tests the field plugin manager.

Namespace

Drupal\Tests\migrate_drupal\Kernel

Code

public function testPluginSelection() {
  $this
    ->assertSame('link', $this->pluginManager
    ->getPluginIdFromFieldType('link', [
    'core' => 6,
  ]));
  $this
    ->assertSame('link_field', $this->pluginManager
    ->getPluginIdFromFieldType('link_field', [
    'core' => 7,
  ]));
  $this
    ->assertSame('image', $this->pluginManager
    ->getPluginIdFromFieldType('image', [
    'core' => 7,
  ]));
  $this
    ->assertSame('file', $this->pluginManager
    ->getPluginIdFromFieldType('file', [
    'core' => 7,
  ]));
  $this
    ->assertSame('d6_file', $this->pluginManager
    ->getPluginIdFromFieldType('file', [
    'core' => 6,
  ]));
  $this
    ->assertSame('d6_text', $this->pluginManager
    ->getPluginIdFromFieldType('text', [
    'core' => 6,
  ]));
  $this
    ->assertSame('d7_text', $this->pluginManager
    ->getPluginIdFromFieldType('text', [
    'core' => 7,
  ]));

  // Test that the deprecated d6 'date' plugin is not returned.
  $this
    ->assertSame('datetime', $this->pluginManager
    ->getPluginIdFromFieldType('date', [
    'core' => 6,
  ]));

  // Test fallback when no core version is specified.
  $this
    ->assertSame('d6_no_core_version_specified', $this->pluginManager
    ->getPluginIdFromFieldType('d6_no_core_version_specified', [
    'core' => 6,
  ]));
}