function PluginDependencyTraitTest::testCalculatePluginDependencies

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Plugin/PluginDependencyTraitTest.php \Drupal\Tests\Core\Plugin\PluginDependencyTraitTest::testCalculatePluginDependencies()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/PluginDependencyTraitTest.php \Drupal\Tests\Core\Plugin\PluginDependencyTraitTest::testCalculatePluginDependencies()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/PluginDependencyTraitTest.php \Drupal\Tests\Core\Plugin\PluginDependencyTraitTest::testCalculatePluginDependencies()

@covers ::calculatePluginDependencies

@dataProvider providerTestPluginDependencies

Parameters

\Prophecy\Prophecy\ProphecyInterface $plugin: A prophecy of a plugin instance.

mixed $definition: A plugin definition.

array $expected: The expected dependencies.

File

core/tests/Drupal/Tests/Core/Plugin/PluginDependencyTraitTest.php, line 58

Class

PluginDependencyTraitTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21PluginDependencyTrait.php/trait/PluginDependencyTrait/9" title="Provides a trait for calculating the dependencies of a plugin." class="local">\Drupal\Core\Plugin\PluginDependencyTrait</a> @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCalculatePluginDependencies(ProphecyInterface $plugin, $definition, array $expected) {
    $test_class = new TestPluginDependency();
    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $module_handler->moduleExists('test_module1')
        ->willReturn(TRUE);
    $module_handler->moduleExists('test_theme1')
        ->willReturn(FALSE);
    $test_class->setModuleHandler($module_handler->reveal());
    $theme_handler = $this->prophesize(ThemeHandlerInterface::class);
    $theme_handler->themeExists('test_module1')
        ->willReturn(FALSE);
    $theme_handler->themeExists('test_theme1')
        ->willReturn(TRUE);
    $test_class->setThemeHandler($theme_handler->reveal());
    $plugin->getPluginDefinition()
        ->willReturn($definition);
    $test_class->calculatePluginDependencies($plugin->reveal());
    $this->assertEquals($expected, $test_class->getDependencies());
}

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