You are here

public function InfoParserUnitTest::testInfoParserCommonInfo 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::testInfoParserCommonInfo()

Tests common info file.

@covers ::parse

File

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

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

public function testInfoParserCommonInfo() {
  $common = <<<COMMONTEST
core_version_requirement: '*'
name: common_test
type: module
description: 'testing info file parsing'
simple_string: 'A simple string'
version: "VERSION"
double_colon: dummyClassName::method
COMMONTEST;
  vfsStream::setup('modules');
  foreach ([
    '1',
    '2',
  ] as $file_delta) {
    $filename = "common_test-{$file_delta}.info.txt";
    vfsStream::create([
      'fixtures' => [
        $filename => $common,
      ],
    ]);
    $info_values = $this->infoParser
      ->parse(vfsStream::url("modules/fixtures/{$filename}"));
    $this
      ->assertEquals($info_values['simple_string'], 'A simple string', 'Simple string value was parsed correctly.');
    $this
      ->assertEquals($info_values['version'], \Drupal::VERSION, 'Constant value was parsed correctly.');
    $this
      ->assertEquals($info_values['double_colon'], 'dummyClassName::method', 'Value containing double-colon was parsed correctly.');
    $this
      ->assertFalse($info_values['core_incompatible']);
  }
}