function InfoParserUnitTest::testInfoParserMissingKeys

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserMissingKeys()

Tests that missing required keys are detected.

@covers ::parse

File

core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php, line 86

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

public function testInfoParserMissingKeys() {
    $missing_keys = <<<MISSINGKEYS
# info.yml for testing missing name, description, and type keys.
package: Core
version: VERSION
dependencies:
  - field
MISSINGKEYS;
    vfsStream::setup('modules');
    vfsStream::create([
        'fixtures' => [
            'missing_keys.info.txt' => $missing_keys,
        ],
    ]);
    $filename = vfsStream::url('modules/fixtures/missing_keys.info.txt');
    $this->expectException('\\Drupal\\Core\\Extension\\InfoParserException');
    $this->expectExceptionMessage('Missing required keys (type, name) in vfs://modules/fixtures/missing_keys.info.txt');
    $this->infoParser
        ->parse($filename);
}

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