function InfoParserUnitTest::testInfoParserMissingKey
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserMissingKey()
Tests that missing required key is detected.
@covers ::parse
File
-
core/
tests/ Drupal/ Tests/ Core/ Extension/ InfoParserUnitTest.php, line 335
Class
- InfoParserUnitTest
- Tests InfoParser class and exception.
Namespace
Drupal\Tests\Core\ExtensionCode
public function testInfoParserMissingKey() {
$missing_key = <<<MISSINGKEY
# info.yml for testing missing type key.
name: File
description: 'Defines a file field type.'
package: Core
version: VERSION
core: 8.x
dependencies:
- field
MISSINGKEY;
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
'missing_key.info.txt' => $missing_key,
'missing_key-duplicate.info.txt' => $missing_key,
],
]);
// Set the expected exception for the 2nd call to parse().
$this->expectException(InfoParserException::class);
$this->expectExceptionMessage('Missing required keys (type) in vfs://modules/fixtures/missing_key-duplicate.info.txt');
try {
$this->infoParser
->parse(vfsStream::url('modules/fixtures/missing_key.info.txt'));
} catch (InfoParserException $exception) {
$this->assertSame('Missing required keys (type) in vfs://modules/fixtures/missing_key.info.txt', $exception->getMessage());
$this->infoParser
->parse(vfsStream::url('modules/fixtures/missing_key-duplicate.info.txt'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.