YamlDiscoveryTest.php in Drupal 10
File
core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php
View source
<?php
namespace Drupal\Tests\Core\Discovery;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Core\Discovery\YamlDiscovery;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use org\bovigo\vfs\vfsStreamWrapper;
use PHPUnit\Framework\TestCase;
class YamlDiscoveryTest extends TestCase {
protected function setUp() : void {
FileCacheFactory::setPrefix('prefix');
}
public function testFilenameForBrokenYml() {
vfsStreamWrapper::register();
$root = new vfsStreamDirectory('modules');
vfsStreamWrapper::setRoot($root);
$url = vfsStream::url('modules');
mkdir($url . '/test_broken');
file_put_contents($url . '/test_broken/test_broken.test.yml', "broken:\n:");
$this
->expectException(InvalidDataTypeException::class);
$this
->expectExceptionMessage('vfs://modules/test_broken/test_broken.test.yml');
$directories = [
'test_broken' => $url . '/test_broken',
];
$discovery = new YamlDiscovery('test', $directories);
$discovery
->findAll();
}
}