function DefaultLazyPluginCollectionTest::testConfigurableInterface

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

Class

DefaultLazyPluginCollectionTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21DefaultLazyPluginCollection.php/class/DefaultLazyPluginCollection/11.x" title="Provides a default plugin collection for a plugin type." class="local">\Drupal\Core\Plugin\DefaultLazyPluginCollection</a> @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testConfigurableInterface() : void {
    $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());
}

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