function DefaultLazyPluginCollectionTest::testConfigurableSetConfiguration

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

@covers ::setConfiguration

File

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

Class

DefaultLazyPluginCollectionTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21DefaultLazyPluginCollection.php/class/DefaultLazyPluginCollection/8.9.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 testConfigurableSetConfiguration() {
    $this->setupPluginCollection($this->exactly(2));
    $this->defaultPluginCollection
        ->setConfiguration([
        'apple' => [
            'value' => 'pineapple',
            'id' => 'apple',
        ],
    ]);
    $config = $this->defaultPluginCollection
        ->getConfiguration();
    $this->assertSame([
        'apple' => [
            'value' => 'pineapple',
            'id' => 'apple',
        ],
    ], $config);
    $plugin = $this->pluginInstances['apple'];
    $this->assertSame([
        'value' => 'pineapple',
        'id' => 'apple',
    ], $plugin->getConfiguration());
    $this->defaultPluginCollection
        ->setConfiguration([
        'cherry' => [
            'value' => 'kiwi',
            'id' => 'cherry',
        ],
    ]);
    $expected['cherry'] = [
        'value' => 'kiwi',
        'id' => 'cherry',
    ];
    $config = $this->defaultPluginCollection
        ->getConfiguration();
    $this->assertSame([
        'cherry' => [
            'value' => 'kiwi',
            'id' => 'cherry',
        ],
    ], $config);
}

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