function InfoParserUnitTest::testInfoParserCommonInfo

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

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

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