function DefaultLazyPluginCollectionTest::testGetConfiguration

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultLazyPluginCollectionTest::testGetConfiguration()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/DefaultLazyPluginCollectionTest.php \Drupal\Tests\Core\Plugin\DefaultLazyPluginCollectionTest::testGetConfiguration()
  3. 10 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 98

Class

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

Namespace

Drupal\Tests\Core\Plugin

Code

public function testGetConfiguration() : void {
    $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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.