You are here

public function DefaultLazyPluginCollectionTest::testConfigurableInterface in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultLazyPluginCollectionTest::testConfigurableInterface()

Tests that plugin methods are correctly attached to interfaces.

@covers ::getConfiguration

File

core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php, line 247

Class

DefaultLazyPluginCollectionTest
@coversDefaultClass \Drupal\Core\Plugin\DefaultLazyPluginCollection @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testConfigurableInterface() {
  $configurable_plugin = $this
    ->prophesize(ConfigurableInterface::class);
  $configurable_config = [
    'id' => 'configurable',
    'foo' => 'bar',
  ];
  $configurable_plugin
    ->getConfiguration()
    ->willReturn($configurable_config);
  $nonconfigurable_plugin = $this
    ->prophesize(PluginInspectionInterface::class);
  $nonconfigurable_config = [
    'id' => 'non-configurable',
    'baz' => 'qux',
  ];
  $nonconfigurable_plugin->configuration = $nonconfigurable_config;
  $configurations = [
    'configurable' => $configurable_config,
    'non-configurable' => $nonconfigurable_config,
  ];
  $plugin_manager = $this
    ->prophesize(PluginManagerInterface::class);
  $plugin_manager
    ->createInstance('configurable', $configurable_config)
    ->willReturn($configurable_plugin
    ->reveal());
  $plugin_manager
    ->createInstance('non-configurable', $nonconfigurable_config)
    ->willReturn($nonconfigurable_plugin
    ->reveal());
  $collection = new DefaultLazyPluginCollection($plugin_manager
    ->reveal(), $configurations);
  $this
    ->assertSame($configurations, $collection
    ->getConfiguration());
}