3 namespace Drupal\Tests\migrate_drupal\Kernel;
5 use Drupal\Component\Plugin\Exception\PluginNotFoundException;
8 * Tests the cck field plugin manager.
10 * @group migrate_drupal
12 class MigrateCckFieldPluginManagerTest extends MigrateDrupalTestBase {
17 public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'migrate_cckfield_plugin_manager_test'];
20 * Tests that the correct MigrateCckField plugins are used.
22 public function testPluginSelection() {
23 $plugin_manager = \Drupal::service('plugin.manager.migrate.cckfield');
25 $this->assertSame('d6_file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 6]));
28 // If this test passes, getPluginIdFromFieldType will raise a
29 // PluginNotFoundException and we'll never reach fail().
30 $plugin_manager->getPluginIdFromFieldType('d6_file', ['core' => 7]);
31 $this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
33 catch (PluginNotFoundException $e) {
34 $this->assertSame($e->getMessage(), "Plugin ID 'd6_file' was not found.");
37 // Test fallback when no core version is specified.
38 $this->assertSame('d6_no_core_version_specified', $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 6]));
41 // If this test passes, getPluginIdFromFieldType will raise a
42 // PluginNotFoundException and we'll never reach fail().
43 $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 7]);
44 $this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
46 catch (PluginNotFoundException $e) {
47 $this->assertSame($e->getMessage(), "Plugin ID 'd6_no_core_version_specified' was not found.");