3 namespace Drupal\Tests\migrate_drupal\Kernel;
5 use Drupal\Component\Plugin\Exception\PluginNotFoundException;
8 * Tests the field plugin manager.
10 * @group migrate_drupal
12 class MigrateFieldPluginManagerTest extends MigrateDrupalTestBase {
17 public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'link', 'migrate_field_plugin_manager_test'];
20 * Tests that the correct MigrateField plugins are used.
22 public function testPluginSelection() {
23 $plugin_manager = $this->container->get('plugin.manager.migrate.field');
26 // If this test passes, getPluginIdFromFieldType will raise a
27 // PluginNotFoundException and we'll never reach fail().
28 $plugin_manager->getPluginIdFromFieldType('filefield', ['core' => 7]);
29 $this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
31 catch (PluginNotFoundException $e) {
32 $this->assertIdentical($e->getMessage(), "Plugin ID 'filefield' was not found.");
35 $this->assertIdentical('link', $plugin_manager->getPluginIdFromFieldType('link', ['core' => 6]));
36 $this->assertIdentical('link_field', $plugin_manager->getPluginIdFromFieldType('link_field', ['core' => 7]));
37 $this->assertIdentical('image', $plugin_manager->getPluginIdFromFieldType('image', ['core' => 7]));
38 $this->assertIdentical('file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 7]));
39 $this->assertIdentical('d6_file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 6]));
40 $this->assertIdentical('d6_text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 6]));
41 $this->assertIdentical('d7_text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 7]));
43 // Test fallback when no core version is specified.
44 $this->assertIdentical('d6_no_core_version_specified', $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 6]));
47 // If this test passes, getPluginIdFromFieldType will raise a
48 // PluginNotFoundException and we'll never reach fail().
49 $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 7]);
50 $this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
52 catch (PluginNotFoundException $e) {
53 $this->assertIdentical($e->getMessage(), "Plugin ID 'd6_no_core_version_specified' was not found.");