function DefaultSingleLazyPluginCollectionTest::testConfigurableSetConfiguration

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultSingleLazyPluginCollectionTest::testConfigurableSetConfiguration()

@covers ::setConfiguration

File

core/tests/Drupal/Tests/Core/Plugin/DefaultSingleLazyPluginCollectionTest.php, line 78

Class

DefaultSingleLazyPluginCollectionTest
@coversDefaultClass \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testConfigurableSetConfiguration() : void {
    $this->setupPluginCollection($this->any());
    $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([
        'apple' => [
            'value' => 'pineapple',
            'id' => 'apple',
        ],
    ], $plugin->getConfiguration());
    $this->defaultPluginCollection
        ->setConfiguration([]);
    $this->assertSame([], $this->defaultPluginCollection
        ->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.