public function InfoParserUnitTest::testCoreWithoutCoreVersionRequirement in Drupal 9
Tests setting the 'core' key without the 'core_version_requirement' key.
@covers ::parse
@dataProvider providerCoreWithoutCoreVersionRequirement
File
- core/
tests/ Drupal/ Tests/ Core/ Extension/ InfoParserUnitTest.php, line 364
Class
- InfoParserUnitTest
- Tests InfoParser class and exception.
Namespace
Drupal\Tests\Core\ExtensionCode
public function testCoreWithoutCoreVersionRequirement($core) {
$core_without_core_version_requirement = <<<CORE_WITHOUT_CORE_VERSION_REQUIREMENT
package: Dogs
core: {<span class="php-variable">$core</span>}
version: VERSION
type: module
name: Gracie Daily Picture
description: Shows a random picture of Gracie the Dog everyday.
CORE_WITHOUT_CORE_VERSION_REQUIREMENT;
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
"core_without_core_version_requirement-{$core}.info.txt" => $core_without_core_version_requirement,
"core_without_core_version_requirement-{$core}-duplicate.info.txt" => $core_without_core_version_requirement,
],
]);
$exception_message = "'core: {$core}' is not supported. Use 'core_version_requirement' to specify core compatibility. Only 'core: 8.x' is supported to provide backwards compatibility for Drupal 8 when needed in vfs://modules/fixtures/core_without_core_version_requirement-{$core}";
// Set the expected exception for the 2nd call to parse().
$this
->expectException('\\Drupal\\Core\\Extension\\InfoParserException');
$this
->expectExceptionMessage("{$exception_message}-duplicate.info.txt");
try {
$this->infoParser
->parse(vfsStream::url("modules/fixtures/core_without_core_version_requirement-{$core}.info.txt"));
} catch (InfoParserException $exception) {
$this
->assertSame("{$exception_message}.info.txt", $exception
->getMessage());
$this->infoParser
->parse(vfsStream::url("modules/fixtures/core_without_core_version_requirement-{$core}-duplicate.info.txt"));
}
}