You are here

public function InfoParserUnitTest::testInfoParserCommonInfo in Drupal 10

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

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('A simple string', $info_values['simple_string'], 'Simple string value was parsed correctly.');
    $this
      ->assertEquals(\Drupal::VERSION, $info_values['version'], 'Constant value was parsed correctly.');
    $this
      ->assertEquals('dummyClassName::method', $info_values['double_colon'], 'Value containing double-colon was parsed correctly.');
    $this
      ->assertFalse($info_values['core_incompatible']);
  }
}