function InfoParserUnitTest::testInfoException
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoException()
Tests if correct exception is thrown for a broken info file.
@dataProvider providerInfoException
Parameters
string $yaml: The YAML to use to create the file to parse.
string $expected_exception_message: The expected exception message.
File
-
core/
tests/ Drupal/ Tests/ Core/ Extension/ InfoParserUnitTest.php, line 66
Class
- InfoParserUnitTest
- Tests InfoParser class and exception.
Namespace
Drupal\Tests\Core\ExtensionCode
public function testInfoException($yaml, $expected_exception_message) : void {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
"broken.info.txt" => $yaml,
"broken-duplicate.info.txt" => $yaml,
],
]);
try {
$this->infoParser
->parse(vfsStream::url("modules/fixtures/broken.info.txt"));
} catch (InfoParserException $exception) {
$this->assertSame("{$expected_exception_message} vfs://modules/fixtures/broken.info.txt", $exception->getMessage());
}
$this->expectException(InfoParserException::class);
$this->expectExceptionMessage("{$expected_exception_message} vfs://modules/fixtures/broken-duplicate.info.txt");
$this->infoParser
->parse(vfsStream::url("modules/fixtures/broken-duplicate.info.txt"));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.