Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\YamlDiscoveryDecoratorTest::testGetDefinitions()
  2. 9 core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\YamlDiscoveryDecoratorTest::testGetDefinitions()

Tests the getDefinitions() method.

File

core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php, line 75

Class

YamlDiscoveryDecoratorTest
YamlDiscoveryDecorator unit tests.

Namespace

Drupal\Tests\Core\Plugin\Discovery

Code

public function testGetDefinitions() {
  $definitions = $this->discoveryDecorator
    ->getDefinitions();
  $this
    ->assertIsArray($definitions);
  $this
    ->assertCount(6, $definitions);
  foreach ($this->expectedKeys as $expected_key) {
    $this
      ->assertArrayHasKey($expected_key, $definitions);
  }
  foreach ($definitions as $id => $definition) {
    foreach ([
      'name',
      'id',
      'provider',
    ] as $key) {
      $this
        ->assertArrayHasKey($key, $definition);
    }
    $this
      ->assertEquals($id, $definition['id']);
    $this
      ->assertEquals(array_search($id, $this->expectedKeys), $definition['provider']);
  }
}