function MigrateSourceDiscoveryTest::testGetDefinitions
Same name and namespace in other branches
- 11.x core/modules/migrate/tests/src/Kernel/Plugin/source/MigrateSourceDiscoveryTest.php \Drupal\Tests\migrate\Kernel\Plugin\source\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. 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.
$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_multiple_provider_test and now the source plugins from
// the file modules hh should be found.
array_push($expected, 'test_empty');
$this->enableModules([
'migrate_multiple_provider_test',
]);
$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.