public function DefaultLazyPluginCollectionTest::testConfigurableSetConfiguration in Drupal 9
Same name and namespace in other branches
- 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 
Class
- DefaultLazyPluginCollectionTest
- @coversDefaultClass \Drupal\Core\Plugin\DefaultLazyPluginCollection @group Plugin
Namespace
Drupal\Tests\Core\PluginCode
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);
}