function MigrateSourceDiscoveryTest::testGetDefinitions
@covers \Drupal\migrate\Plugin\MigrateSourcePluginManager::getDefinitions
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ Plugin/ source/ MigrateSourceDiscoveryTest.php, line 29
Class
- MigrateSourceDiscoveryTest
- Tests discovery of source plugins with annotations.
Namespace
Drupal\Tests\migrate\Kernel\Plugin\sourceCode
public function testGetDefinitions() : void {
// First, check the expected plugins are provided by migrate only.
$expected = [
'embedded_data',
'empty',
];
$source_plugins = \Drupal::service('plugin.manager.migrate.source')->getDefinitions();
ksort($source_plugins);
$this->assertSame($expected, array_keys($source_plugins));
// Next, install the file module, which has 4 migrate source plugins, all of
// which depend on migrate_drupal. Since migrate_drupal is not installed,
// none of the source plugins from file should be discovered. However, the
// content_entity source for the file entity type should be discovered.
$expected = [
'content_entity:file',
'embedded_data',
'empty',
];
$this->enableModules([
'file',
]);
$source_plugins = \Drupal::service('plugin.manager.migrate.source')->getDefinitions();
ksort($source_plugins);
$this->assertSame($expected, array_keys($source_plugins));
// Install migrate_drupal and now the source plugins from the file modules
// should be found.
$expected = [
'd6_file',
'd6_upload',
'd6_upload_instance',
'd7_file',
'embedded_data',
'empty',
];
$this->enableModules([
'migrate_drupal',
]);
$source_plugins = \Drupal::service('plugin.manager.migrate.source')->getDefinitions();
$this->assertSame(array_diff($expected, array_keys($source_plugins)), []);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.