You are here

public function DefaultLazyPluginCollectionTest::testConfigurableSetConfiguration in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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
Contains \Drupal\Tests\Core\Plugin\DefaultLazyPluginCollectionTest.

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([
    'cherry' => [
      'value' => 'kiwi',
      'id' => 'cherry',
    ],
  ], $config);
}