vfsStream::
url('modules/test_2/subdir2'
),
],
// Directories that do not exist.
'test_3' =>
[ vfsStream::
url('modules/test_3/subdir1'
),
vfsStream::
url('modules/test_3/subdir2'
),
],
// A single directory.
'test_4' => vfsStream::
url('modules/test_4/subdir1'
),
];
$discovery =
new YamlDirectoryDiscovery($directories, 'test'
);
$data =
$discovery->
findAll();
// The file path is dependent on the operating system, so we adjust the directory separator.
$this->
assertSame(['id' => 'item1', 'name' => 'test1 item 1', YamlDirectoryDiscovery::FILE_KEY => 'vfs://modules/test_1/subdir1' . DIRECTORY_SEPARATOR . 'item_1.test.yml'
],
$data['test_1'
]['item1'
]);
$this->
assertSame(['id' => 'item2', 'name' => 'test1 item 2', YamlDirectoryDiscovery::FILE_KEY => 'vfs://modules/test_1/subdir2' . DIRECTORY_SEPARATOR . 'item_2.test.yml'
],
$data['test_1'
]['item2'
]);
$this->
assertCount(2,
$data['test_1'
]);
$this->
assertSame(['id' => 'item3', 'name' => 'test2 item 3', YamlDirectoryDiscovery::FILE_KEY => 'vfs://modules/test_2/subdir1' . DIRECTORY_SEPARATOR . 'item_3.test.yml'
],
$data['test_2'
]['item3'
]);
$this->
assertCount(1,
$data['test_2'
]);
$this->
assertArrayNotHasKey('test_3',
$data, 'test_3 provides 0 items'
);