You are here

public function YamlDirectoryDiscoveryTest::testDiscoveryNoIdException in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDirectoryDiscoveryTest::testDiscoveryNoIdException()

Tests YAML directory discovery with a missing ID key.

@covers ::findAll @covers ::getIdentifier

File

core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php, line 126

Class

YamlDirectoryDiscoveryTest
YamlDirectoryDiscoveryTest component unit tests.

Namespace

Drupal\Tests\Component\Discovery

Code

public function testDiscoveryNoIdException() {
  $this
    ->expectException(DiscoveryException::class);
  $this
    ->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
  vfsStream::setup('modules', NULL, [
    'test_1' => [
      'item_1.test.yml' => "",
    ],
  ]);

  // Set up the directories to search.
  $directories = [
    'test_1' => vfsStream::url('modules/test_1'),
  ];
  $discovery = new YamlDirectoryDiscovery($directories, 'test');
  $discovery
    ->findAll();
}