You are here

public function DefaultLazyPluginCollectionTest::testGetConfiguration 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::testGetConfiguration()

@covers ::getConfiguration

File

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

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 = array(
    '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.');
}