You are here

public function DefaultLazyPluginCollectionTest::testConfigurableSetConfiguration in Drupal 8

Same name and namespace in other branches
  1. 9 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([
    'cherry' => [
      'value' => 'kiwi',
      'id' => 'cherry',
    ],
  ], $config);
}