You are here

public function DefaultLazyPluginCollectionTest::testGetConfiguration in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultLazyPluginCollectionTest::testGetConfiguration()
  2. 9 core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultLazyPluginCollectionTest::testGetConfiguration()

@covers ::getConfiguration

File

core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php, line 96

Class

DefaultLazyPluginCollectionTest
@coversDefaultClass \Drupal\Core\Plugin\DefaultLazyPluginCollection @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testGetConfiguration() {
  $this
    ->setupPluginCollection($this
    ->exactly(3));

  // The expected order matches $this->config.
  $expected = [
    'banana',
    'cherry',
    'apple',
  ];
  $config = $this->defaultPluginCollection
    ->getConfiguration();
  $this
    ->assertSame($expected, array_keys($config), 'The order of the configuration is unchanged.');
  $ids = $this->defaultPluginCollection
    ->getInstanceIds();
  $this
    ->assertSame($expected, array_keys($ids), 'The order of the instances is unchanged.');
  $this->defaultPluginCollection
    ->sort();
  $config = $this->defaultPluginCollection
    ->getConfiguration();
  $this
    ->assertSame($expected, array_keys($config), 'After sorting, the order of the configuration is unchanged.');
  $ids = $this->defaultPluginCollection
    ->getInstanceIds();
  sort($expected);
  $this
    ->assertSame($expected, array_keys($ids), 'After sorting, the order of the instances is also sorted.');
}