function YamlDiscoveryTest::testForBrokenYml

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest::testForBrokenYml()
  2. 10 core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest::testForBrokenYml()
  3. 11.x core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest::testForBrokenYml()

Tests if filename is output for a broken YAML file.

File

core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php, line 74

Class

YamlDiscoveryTest
YamlDiscovery component unit tests.

Namespace

Drupal\Tests\Component\Discovery

Code

public function testForBrokenYml() {
    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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.