function PluginDependencyTraitTest::providerTestPluginDependencies

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/PluginDependencyTraitTest.php \Drupal\Tests\Core\Plugin\PluginDependencyTraitTest::providerTestPluginDependencies()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/PluginDependencyTraitTest.php \Drupal\Tests\Core\Plugin\PluginDependencyTraitTest::providerTestPluginDependencies()
  3. 10 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 83

Class

PluginDependencyTraitTest
@coversDefaultClass \Drupal\Core\Plugin\PluginDependencyTrait @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public static function providerTestPluginDependencies() {
    $prophet = new Prophet();
    $data = [];
    $plugin = $prophet->prophesize(PluginInspectionInterface::class);
    $dependent_plugin = $prophet->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 = $prophet->prophesize(PluginDefinitionInterface::class);
    $definition->getProvider()
        ->willReturn('test_module1');
    $data['object_definition'] = [
        $plugin,
        $definition->reveal(),
        [
            'module' => [
                'test_module1',
            ],
        ],
    ];
    $dependent_definition = $prophet->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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.