function DefaultLazyPluginCollectionTest::testConfigurableSetConfiguration

Same name in other branches
  1. 8.9.x 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 \Drupal\Core\Plugin\DefaultLazyPluginCollection @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($expected, $config);
}

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