public function YamlDirectoryDiscoveryTest::testDiscoveryAlternateId in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDirectoryDiscoveryTest::testDiscoveryAlternateId()
Tests YAML directory discovery with an alternate ID key.
@covers ::findAll
File
- core/
tests/ Drupal/ Tests/ Component/ Discovery/ YamlDirectoryDiscoveryTest.php, line 103
Class
- YamlDirectoryDiscoveryTest
- YamlDirectoryDiscoveryTest component unit tests.
Namespace
Drupal\Tests\Component\DiscoveryCode
public function testDiscoveryAlternateId() {
vfsStream::setup('modules', NULL, [
'test_1' => [
'item_1.test.yml' => "alt_id: item1\nid: ignored",
],
]);
// Set up the directories to search.
$directories = [
'test_1' => vfsStream::url('modules/test_1'),
];
$discovery = new YamlDirectoryDiscovery($directories, 'test', 'alt_id');
$data = $discovery
->findAll();
$this
->assertSame([
'alt_id' => 'item1',
'id' => 'ignored',
YamlDirectoryDiscovery::FILE_KEY => 'vfs://modules/test_1/item_1.test.yml',
], $data['test_1']['item1']);
$this
->assertCount(1, $data['test_1']);
}