You are here

public function YamlDiscoveryTest::testFilenameForBrokenYml in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Discovery\YamlDiscoveryTest::testFilenameForBrokenYml()
  2. 9 core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Discovery\YamlDiscoveryTest::testFilenameForBrokenYml()

Tests if filename is output for a broken YAML file.

File

core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php, line 31

Class

YamlDiscoveryTest
YamlDiscovery component unit tests.

Namespace

Drupal\Tests\Core\Discovery

Code

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();
}