function MigrateSourceDiscoveryTest::testAnnotationGetDefinitionsBackwardsCompatibility
@covers \Drupal\migrate\Plugin\MigrateSourcePluginManager::getDefinitions
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ Plugin/ source/ MigrateSourceDiscoveryTest.php, line 64
Class
- MigrateSourceDiscoveryTest
- Tests discovery of source plugins with annotations.
Namespace
Drupal\Tests\migrate\Kernel\Plugin\sourceCode
public function testAnnotationGetDefinitionsBackwardsCompatibility() : void {
// First, test attribute-only discovery.
$expected = [
'embedded_data',
'empty',
];
$source_plugins = \Drupal::service('plugin.manager.migrate.source')->getDefinitions();
ksort($source_plugins);
$this->assertSame($expected, array_keys($source_plugins));
// Next, test discovery of both attributed and annotated plugins. The
// annotated plugin with multiple providers depends on migrate_drupal and
// should not be discovered with it uninstalled.
$expected = [
'annotated',
'embedded_data',
'empty',
];
$this->enableModules([
'migrate_source_annotation_bc_test',
]);
$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 annotated plugin that depends on it
// should be discovered.
$expected = [
'annotated',
'annotated_multiple_providers',
'embedded_data',
'empty',
];
$this->enableModules([
'migrate_drupal',
]);
$source_plugins = \Drupal::service('plugin.manager.migrate.source')->getDefinitions();
// Confirming here the that the source plugins that migrate and
// migrate_source_annotation_bc_test are discovered. There are additional
// plugins provided by migrate_drupal, but they do not need to be enumerated
// here.
$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.