function InfoParserUnitTest::testInfoParserCommonInfo

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserCommonInfo()
  2. 8.9.x core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php \Drupal\Tests\Core\Extension\InfoParserUnitTest::testInfoParserCommonInfo()
  3. 10 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 185

Class

InfoParserUnitTest
Tests InfoParser class and exception.

Namespace

Drupal\Tests\Core\Extension

Code

public function testInfoParserCommonInfo() : void {
    $common = <<<COMMON
core_version_requirement: '*'
name: common_test
type: module
description: 'testing info file parsing'
simple_string: 'A simple string'
version: "VERSION"
double_colon: dummyClassName::method
COMMON;
    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']);
    }
}

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