function MigrateSourceDiscoveryTest::testGetDefinitions
Tests get definitions.
@legacy-covers \Drupal\migrate\Plugin\MigrateSourcePluginManager::getDefinitions
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ Plugin/ source/ MigrateSourceDiscoveryTest.php, line 33
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 = [
'config_entity',
'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. Note that the
// content_entity:file plugin should not be discovered either, because it
// has an implicit dependency on the user module which has not been
// installed.
$expected = [
'config_entity',
'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 user and 'content_entity:file', 'content_entity:user' should now
// be discovered. The other source plugins in the user modules all depend
// on migrate_drupal, so those should not be discovered, either.
$expected = [
'config_entity',
'content_entity:file',
'content_entity:user',
'embedded_data',
'empty',
];
$this->enableModules([
'user',
]);
$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 = [
'config_entity',
'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.