You are here

public function InfoParserUnitTest::testInfoParserMissingKey in Zircon Profile 8

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

Tests that missing required key is detected.

@covers ::parse

@expectedException \Drupal\Core\Extension\InfoParserException @expectedExceptionMessageRegExp #Missing required keys \(type\) in .+?missing_key\.info\.txt#

File

core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php, line 120
Contains \Drupal\Tests\Core\Extension\InfoParserUnitTest.

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

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,
    ],
  ]);
  $filename = vfsStream::url('modules/fixtures/missing_key.info.txt');
  $this->infoParser
    ->parse($filename);
}