You are here

public function InfoParserUnitTest::testInfoParserMissingKeys in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserMissingKeys()
  2. 10 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 85

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