public function PluginDependencyTraitTest::providerTestPluginDependencies in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Plugin/PluginDependencyTraitTest.php \Drupal\Tests\Core\Plugin\PluginDependencyTraitTest::providerTestPluginDependencies()
Provides test data for plugin dependencies.
File
- core/
tests/ Drupal/ Tests/ Core/ Plugin/ PluginDependencyTraitTest.php, line 80
Class
- PluginDependencyTraitTest
- @coversDefaultClass \Drupal\Core\Plugin\PluginDependencyTrait @group Plugin
Namespace
Drupal\Tests\Core\PluginCode
public function providerTestPluginDependencies() {
$data = [];
$plugin = $this
->prophesize(PluginInspectionInterface::class);
$dependent_plugin = $this
->prophesize(PluginInspectionInterface::class)
->willImplement(DependentPluginInterface::class);
$dependent_plugin
->calculateDependencies()
->willReturn([
'module' => [
'test_module2',
],
]);
$data['dependent_plugin_from_module'] = [
$dependent_plugin,
[
'provider' => 'test_module1',
],
[
'module' => [
'test_module1',
'test_module2',
],
],
];
$data['dependent_plugin_from_core'] = [
$dependent_plugin,
[
'provider' => 'core',
],
[
'module' => [
'core',
'test_module2',
],
],
];
$data['dependent_plugin_from_theme'] = [
$dependent_plugin,
[
'provider' => 'test_theme1',
],
[
'module' => [
'test_module2',
],
'theme' => [
'test_theme1',
],
],
];
$data['array_with_config_dependencies'] = [
$plugin,
[
'provider' => 'test_module1',
'config_dependencies' => [
'module' => [
'test_module2',
],
],
],
[
'module' => [
'test_module1',
'test_module2',
],
],
];
$definition = $this
->prophesize(PluginDefinitionInterface::class);
$definition
->getProvider()
->willReturn('test_module1');
$data['object_definition'] = [
$plugin,
$definition
->reveal(),
[
'module' => [
'test_module1',
],
],
];
$dependent_definition = $this
->prophesize(PluginDefinitionInterface::class)
->willImplement(DependentPluginDefinitionInterface::class);
$dependent_definition
->getProvider()
->willReturn('test_module1');
$dependent_definition
->getConfigDependencies()
->willReturn([
'module' => [
'test_module2',
],
]);
$data['dependent_object_definition'] = [
$plugin,
$dependent_definition
->reveal(),
[
'module' => [
'test_module1',
'test_module2',
],
],
];
return $data;
}