diff --git a/core/modules/system/src/ModuleDependencyMessageTrait.php b/core/modules/system/src/ModuleDependencyMessageTrait.php
index febfbfa43f..e61a8ebfe5 100644
--- a/core/modules/system/src/ModuleDependencyMessageTrait.php
+++ b/core/modules/system/src/ModuleDependencyMessageTrait.php
@@ -2,14 +2,14 @@
namespace Drupal\system;
-use Drupal\Core\Extension\Dependency;
+use Drupal\Core\Extension\Dependency\DependencyInterface;
/**
* Messages for missing or incompatible dependencies on modules.
*
- * @internal The trait simply helps core classes that display user messages
- * regarding missing or incompatible module dependencies share exact same
- * wording and markup.
+ * @internal This trait helps core classes that display user messages regarding
+ * missing or incompatible module dependencies share exact same wording and
+ * markup.
*/
trait ModuleDependencyMessageTrait {
@@ -20,13 +20,13 @@ trait ModuleDependencyMessageTrait {
* The list of existing modules.
* @param string $dependency
* The module dependency to check.
- * @param \Drupal\Core\Extension\Dependency $dependency_object
+ * @param \Drupal\Core\Extension\DependencyInterface $dependency_object
* Dependency object used for comparing version requirement data.
*
* @return string|null
* NULL if compatible, otherwise a string describing the incompatibility.
*/
- public function checkDependencyMessage(array $modules, $dependency, Dependency $dependency_object) {
+ public function checkDependencyMessage(array $modules, $dependency, DependencyInterface $dependency_object) {
if (!isset($modules[$dependency])) {
return $this->t('@module_name (missing)', ['@module_name' => $dependency]);
}
diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
index 804527d319..f5d68373cc 100644
--- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
@@ -141,7 +141,7 @@ public function providerDependencyInvalidCoreInstall() {
return [
'info with info.yml dependency' => [
'system_incompatible_core_version_dependencies_test',
- 'system_incompatible_core_version_test',
+ 'system_core_incompatible_semver_test',
],
'composer.json with info.yml dependency' => [
'composer_incompatible_core_depend_test',
diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php
index 62efc21d18..f42eb5e417 100644
--- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php
@@ -11,10 +11,6 @@
/**
* Tests InfoParser class and exception.
*
- * Files for this test are stored in core/modules/system/tests/fixtures and end
- * with .info.txt instead of info.yml in order not to be considered as real
- * extensions.
- *
* @coversDefaultClass \Drupal\Core\Extension\InfoParser
*
* @group Extension
@@ -54,7 +50,7 @@ protected function setUp(): void {
*/
public function testInfoParserNonExisting() {
vfsStream::setup('modules');
- $info = $this->infoParser->parse(vfsStream::url('modules') . '/does_not_exist.info.txt');
+ $info = $this->infoParser->parse(vfsStream::url('modules') . '/does_not_exist.info.yml');
$this->assertTrue(empty($info), 'Non existing info.yml returns empty array.');
}
@@ -79,12 +75,12 @@ public function testInfoParserBroken() {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
- 'broken.info.txt' => $broken_info,
+ 'broken.info.yml' => $broken_info,
],
]);
- $filename = vfsStream::url('modules/fixtures/broken.info.txt');
- $this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage('broken.info.txt');
+ $filename = vfsStream::url('modules/fixtures/broken.info.yml');
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage('broken.info.yml');
$this->infoParser->parse($filename);
}
@@ -106,14 +102,14 @@ public function testInfoParserMissingKeys($create_composer_json) {
vfsStream::setup('modules');
$fixtures = [
'fixtures' => [
- 'missing_keys.info.txt' => $missing_keys,
+ 'missing_keys.info.yml' => $missing_keys,
],
];
$this->addIgnoredComposerJson($create_composer_json, $fixtures);
vfsStream::create($fixtures);
- $filename = vfsStream::url('modules/fixtures/missing_keys.info.txt');
- $this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage('Missing required keys (type, name) in vfs://modules/fixtures/missing_keys.info.txt');
+ $filename = vfsStream::url('modules/fixtures/missing_keys.info.yml');
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage('Missing required keys (type, name) in vfs://modules/fixtures/missing_keys.info.yml');
$this->infoParser->parse($filename);
}
@@ -133,21 +129,22 @@ public function testMissingCoreCoreVersionRequirement() {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
- 'missing_core_and_core_version_requirement.info.txt' => $missing_core_and_core_version_requirement,
- 'missing_core_and_core_version_requirement-duplicate.info.txt' => $missing_core_and_core_version_requirement,
+ 'missing_core_and_core_version_requirement.info.yml' => $missing_core_and_core_version_requirement,
+ 'missing_core_and_core_version_requirement-duplicate.info.yml' => $missing_core_and_core_version_requirement,
],
]);
$exception_message = "If the 'core' or 'core_version_requirement' key is not provided, a composer.json file is required in vfs://modules/fixtures/missing_core_and_core_version_requirement";
// Set the expected exception for the 2nd call to parse().
- $this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage("$exception_message-duplicate.info.txt");
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage("$exception_message-duplicate.info.yml");
try {
- $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_and_core_version_requirement.info.txt'));
- } catch (InfoParserException $exception) {
- $this->assertSame("$exception_message.info.txt", $exception->getMessage());
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_and_core_version_requirement.info.yml'));
+ }
+ catch (InfoParserException $exception) {
+ $this->assertSame("$exception_message.info.yml", $exception->getMessage());
- $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_and_core_version_requirement-duplicate.info.txt'));
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_and_core_version_requirement-duplicate.info.yml'));
}
}
@@ -169,12 +166,12 @@ public function testTestingPackageMissingCoreCoreVersionRequirement($create_comp
vfsStream::setup('modules');
$fixtures = [
'fixtures' => [
- 'missing_core_and_core_version_requirement.info.txt' => $missing_core_and_core_version_requirement,
+ 'missing_core_and_core_version_requirement.info.yml' => $missing_core_and_core_version_requirement,
],
];
$this->addIgnoredComposerJson($create_composer_json, $fixtures);
vfsStream::create($fixtures);
- $info_values = $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_and_core_version_requirement.info.txt'));
+ $info_values = $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_and_core_version_requirement.info.yml'));
$this->assertSame($info_values['core_version_requirement'], \Drupal::VERSION);
$this->assertComposerJsonIgnored($info_values);
}
@@ -199,7 +196,7 @@ public function testCoreVersionRequirement88($create_composer_json) {
vfsStream::setup('modules');
foreach (['1', '2'] as $file_delta) {
- $filename = "core_version_requirement-$file_delta.info.txt";
+ $filename = "core_version_requirement-$file_delta.info.yml";
$fixtures = [
'fixtures' => [
$filename => $core_version_requirement,
@@ -234,26 +231,31 @@ public function testCoreCoreVersionRequirement88() {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
- 'core_and_core_version_requirement_88.info.txt' => $core_and_core_version_requirement_88,
- 'core_and_core_version_requirement_88-duplicate.info.txt' => $core_and_core_version_requirement_88,
+ 'core_and_core_version_requirement_88.info.yml' => $core_and_core_version_requirement_88,
+ 'core_and_core_version_requirement_88-duplicate.info.yml' => $core_and_core_version_requirement_88,
],
]);
$exception_message = "The 'core_version_requirement' constraint (^8.8) requires the 'core' key not be set in vfs://modules/fixtures/core_and_core_version_requirement_88";
// Set the expected exception for the 2nd call to parse().
- $this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage("$exception_message-duplicate.info.txt");
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage("$exception_message-duplicate.info.yml");
try {
- $this->infoParser->parse(vfsStream::url('modules/fixtures/core_and_core_version_requirement_88.info.txt'));
- } catch (InfoParserException $exception) {
- $this->assertSame("$exception_message.info.txt", $exception->getMessage());
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/core_and_core_version_requirement_88.info.yml'));
+ }
+ catch (InfoParserException $exception) {
+ $this->assertSame("$exception_message.info.yml", $exception->getMessage());
- $this->infoParser->parse(vfsStream::url('modules/fixtures/core_and_core_version_requirement_88-duplicate.info.txt'));
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/core_and_core_version_requirement_88-duplicate.info.yml'));
}
}
/**
* Tests a invalid 'core' key.
*
+ * Since we cache the results of parse in InfoParser::parse(), we have to
+ * call it at least twice to ensure the same error makes it through the
+ * cache.
+ *
* @covers ::parse
*
* @dataProvider providerInvalidCore
@@ -273,24 +275,27 @@ public function testInvalidCore($core, $filename) {
- alpaca_detector
INVALID_CORE;
+ $info_filename = "invalid_core-$filename.info.yml";
+
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
- "invalid_core-$filename.info.txt" => $invalid_core,
- "invalid_core-$filename-duplicate.info.txt" => $invalid_core,
+ $info_filename => $invalid_core,
],
]);
- $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/invalid_core-$filename";
+ $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 " . vfsStream::url("modules/fixtures/$info_filename");
// Set the expected exception for the 2nd call to parse().
- $this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage("$exception_message-duplicate.info.txt");
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage($exception_message);
try {
- $this->infoParser->parse(vfsStream::url('modules/fixtures/invalid_core.info.txt'));
- } catch (InfoParserException $exception) {
- $this->assertSame("$exception_message.info.txt", $exception->getMessage());
+ $this->infoParser->parse(vfsStream::url("modules/fixtures/$info_filename"));
+ $this->fail('InfoParser::parse() failed to throw an exception.');
+ }
+ catch (InfoParserException $exception) {
+ $this->assertSame($exception_message, $exception->getMessage());
- $this->infoParser->parse(vfsStream::url("modules/fixtures/invalid_core-$filename-duplicate.info.txt"));
+ $this->infoParser->parse(vfsStream::url("modules/fixtures/$info_filename"));
}
}
@@ -340,13 +345,13 @@ public function testCore8x($core_version_requirement, $filename) {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
- "core_8x-$filename.info.txt" => $core_8x,
- "core_8x-$filename-duplicate.info.txt" => $core_8x,
+ "core_8x-$filename.info.yml" => $core_8x,
+ "core_8x-$filename-duplicate.info.yml" => $core_8x,
],
]);
- $parsed = $this->infoParser->parse(vfsStream::url("modules/fixtures/core_8x-$filename.info.txt"));
+ $parsed = $this->infoParser->parse(vfsStream::url("modules/fixtures/core_8x-$filename.info.yml"));
$this->assertSame($core_version_requirement, $parsed['core_version_requirement']);
- $this->infoParser->parse(vfsStream::url("modules/fixtures/core_8x-$filename-duplicate.info.txt"));
+ $this->infoParser->parse(vfsStream::url("modules/fixtures/core_8x-$filename-duplicate.info.yml"));
$this->assertSame($core_version_requirement, $parsed['core_version_requirement']);
}
@@ -390,21 +395,21 @@ public function testCoreWithoutCoreVersionRequirement($core) {
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,
+ "core_without_core_version_requirement-$core.info.yml" => $core_without_core_version_requirement,
+ "core_without_core_version_requirement-$core-duplicate.info.yml" => $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");
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage("$exception_message-duplicate.info.yml");
try {
- $this->infoParser->parse(vfsStream::url("modules/fixtures/core_without_core_version_requirement-$core.info.txt"));
+ $this->infoParser->parse(vfsStream::url("modules/fixtures/core_without_core_version_requirement-$core.info.yml"));
}
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"));
+ $this->assertSame("$exception_message.info.yml", $exception->getMessage());
+ $this->infoParser->parse(vfsStream::url("modules/fixtures/core_without_core_version_requirement-$core-duplicate.info.yml"));
}
}
@@ -442,20 +447,21 @@ public function testCoreVersionRequirementInvalid($test_case, $constraint) {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
- "invalid_core_version_requirement-$test_case.info.txt" => $invalid_core_version_requirement,
- "invalid_core_version_requirement-$test_case-duplicate.info.txt" => $invalid_core_version_requirement,
+ "invalid_core_version_requirement-$test_case.info.yml" => $invalid_core_version_requirement,
+ "invalid_core_version_requirement-$test_case-duplicate.info.yml" => $invalid_core_version_requirement,
],
]);
$exception_message = "The 'core_version_requirement' can not be used to specify compatibility for a specific version before 8.7.7 in vfs://modules/fixtures/invalid_core_version_requirement-$test_case";
// Set the expected exception for the 2nd call to parse().
- $this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage("$exception_message-duplicate.info.txt");
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage("$exception_message-duplicate.info.yml");
try {
- $this->infoParser->parse(vfsStream::url("modules/fixtures/invalid_core_version_requirement-$test_case.info.txt"));
- } catch (InfoParserException $exception) {
- $this->assertSame("$exception_message.info.txt", $exception->getMessage());
+ $this->infoParser->parse(vfsStream::url("modules/fixtures/invalid_core_version_requirement-$test_case.info.yml"));
+ }
+ catch (InfoParserException $exception) {
+ $this->assertSame("$exception_message.info.yml", $exception->getMessage());
- $this->infoParser->parse(vfsStream::url("modules/fixtures/invalid_core_version_requirement-$test_case-duplicate.info.txt"));
+ $this->infoParser->parse(vfsStream::url("modules/fixtures/invalid_core_version_requirement-$test_case-duplicate.info.yml"));
}
}
@@ -492,23 +498,23 @@ public function testInfoParserMissingKey($create_composer_json) {
vfsStream::setup('modules');
$fixtures = [
'fixtures' => [
- 'missing_key.info.txt' => $missing_key,
- 'missing_key-duplicate.info.txt' => $missing_key,
+ 'missing_key.info.yml' => $missing_key,
+ 'missing_key-duplicate.info.yml' => $missing_key,
],
];
$this->addIgnoredComposerJson($create_composer_json, $fixtures);
vfsStream::create($fixtures);
// Set the expected exception for the 2nd call to parse().
$this->expectException(InfoParserException::class);
- $this->expectExceptionMessage('Missing required keys (type) in vfs://modules/fixtures/missing_key-duplicate.info.txt');
+ $this->expectExceptionMessage('Missing required keys (type) in vfs://modules/fixtures/missing_key-duplicate.info.yml');
try {
- $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_key.info.txt'));
- } catch (InfoParserException $exception) {
- $this->assertSame('Missing required keys (type) in vfs://modules/fixtures/missing_key.info.txt', $exception->getMessage());
-
- $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_key-duplicate.info.txt'));
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_key.info.yml'));
}
+ catch (InfoParserException $exception) {
+ $this->assertSame('Missing required keys (type) in vfs://modules/fixtures/missing_key.info.yml', $exception->getMessage());
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/missing_key-duplicate.info.yml'));
+ }
}
/**
@@ -531,7 +537,7 @@ public function testInfoParserCommonInfo($create_composer_json) {
vfsStream::setup('modules');
foreach (['1', '2'] as $file_delta) {
- $filename = "common_test-$file_delta.info.txt";
+ $filename = "common_test-$file_delta.info.yml";
$fixtures = [
'fixtures' => [
$filename => $common,
@@ -564,7 +570,7 @@ public function testInfoParserCoreInfo($create_composer_json) {
vfsStream::setup('core');
- $filename = "core_test.info.txt";
+ $filename = "core_test.info.yml";
$fixtures = [
'fixtures' => [
$filename => $common,
@@ -590,14 +596,12 @@ public function testCoreIncompatibility($test_case, $constraint, $expected, $cre
name: common_test
type: module
description: 'testing info file parsing'
-simple_string: 'A simple string'
version: "VERSION"
-double_colon: dummyClassName::method
CORE_INCOMPATIBILITY;
vfsStream::setup('modules');
foreach (['1', '2'] as $file_delta) {
- $filename = "core_incompatible-$test_case-$file_delta.info.txt";
+ $filename = "core_incompatible-$test_case-$file_delta.info.yml";
$fixtures = [
'fixtures' => [
$filename => $core_incompatibility,
@@ -667,12 +671,12 @@ public function testProfile($create_composer_json) {
vfsStream::setup('profiles');
$fixtures = [
'fixtures' => [
- 'invalid_profile.info.txt' => $profile,
+ 'invalid_profile.info.yml' => $profile,
],
];
$this->addIgnoredComposerJson($create_composer_json, $fixtures);
vfsStream::create($fixtures);
- $info = $this->infoParser->parse(vfsStream::url('profiles/fixtures/invalid_profile.info.txt'));
+ $info = $this->infoParser->parse(vfsStream::url('profiles/fixtures/invalid_profile.info.yml'));
$this->assertFalse($info['core_incompatible']);
$this->assertComposerJsonIgnored($info);
}
@@ -681,9 +685,8 @@ public function testProfile($create_composer_json) {
* Tests the exception for an unparsable 'core_version_requirement' value.
*
* @covers ::parse
- * @dataProvider providerCreateComposerJson
*/
- public function testUnparsableCoreVersionRequirement($create_composer_json) {
+ public function testUnparsableCoreVersionRequirementWithComposerJson() {
$unparsable_core_version_requirement = << [
- 'unparsable_core_version_requirement.info.txt' => $unparsable_core_version_requirement,
+ 'unparsable_core_version_requirement.info.yml' => $unparsable_core_version_requirement,
+ ],
+ ];
+ $this->addIgnoredComposerJson(TRUE, $fixtures);
+ vfsStream::create($fixtures);
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage("The 'core_version_requirement' constraint (not-this-version) is not a valid value in " . vfsStream::url('modules/fixtures/unparsable_core_version_requirement.info.yml'));
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/unparsable_core_version_requirement.info.yml'));
+ }
+
+ /**
+ * Tests the exception for an unparsable 'core_version_requirement' value.
+ *
+ * @covers ::parse
+ */
+ public function testUnparsableCoreVersionRequirementNoComposerJson() {
+ $unparsable_core_version_requirement = << [
+ 'unparsable_core_version_requirement.info.yml' => $unparsable_core_version_requirement,
],
];
- $this->addIgnoredComposerJson($create_composer_json, $fixtures);
vfsStream::create($fixtures);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessage('Could not parse version constraint not-this-version: Invalid version string "not-this-version"');
- $this->infoParser->parse(vfsStream::url('modules/fixtures/unparsable_core_version_requirement.info.txt'));
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/unparsable_core_version_requirement.info.yml'));
}
-
/**
* Tests a composer.json file.
*
@@ -720,7 +750,6 @@ public function testComposerJson() {
description: 'testing info file parsing'
simple_string: 'A simple string'
version: "VERSION"
-double_colon: dummyClassName::method
COMMONTEST;
$common_json = <<assertFalse(isset($info_values['core']));
$this->assertEquals('module', $info_values['type']);
}
-
}
/**
@@ -783,9 +811,9 @@ public function testComposerJsonTestPackage() {
"type": "drupal-module",
"license": "GPL-2.0-or-later",
"require": {
-"drupal/core": "^8.8",
-"drupal/field": "~8.0",
-"smurfcore/log": "~1.0"
+ "drupal/core": "^8.8",
+ "drupal/field": "~8.0",
+ "smurfcore/log": "~1.0"
},
"version": "VERSION"
}
@@ -810,11 +838,10 @@ public function testComposerJsonTestPackage() {
$this->assertFalse(isset($info_values['core']));
$this->assertEquals('module', $info_values['type']);
}
-
}
/**
- * Tests a composer.json file with invalid 'drupal/core' value.
+ * Tests a composer.json file with an invalid 'drupal/core' value.
*
* @covers ::parse
*/
@@ -823,9 +850,7 @@ public function testComposerInvalidCoreJson() {
name: Common test
type: module
description: 'testing info file parsing'
-simple_string: 'A simple string'
version: "VERSION"
-double_colon: dummyClassName::method
COMMONTEST;
$common_json = <<expectException(InfoParserException::class);
- $this->expectExceptionMessage('Core versions before 8.9.0 must be specified in the module info.yml in vfs://modules/fixtures2/common_no_dependencies.info.yml');
+ $this->expectExceptionMessage('Core versions before 9.1.0 must be specified in the module info.yml file: vfs://modules/fixtures2/common_no_dependencies.info.yml');
try {
$this->infoParser->parse(vfsStream::url("modules/fixtures1/common_no_dependencies.info.yml"));
- } catch (InfoParserException $exception) {
- $this->assertSame('Core versions before 8.9.0 must be specified in the module info.yml in vfs://modules/fixtures1/common_no_dependencies.info.yml', $exception->getMessage());
+ }
+ catch (InfoParserException $exception) {
+ $this->assertSame('Core versions before 9.1.0 must be specified in the module info.yml file: vfs://modules/fixtures1/common_no_dependencies.info.yml', $exception->getMessage());
$this->infoParser->parse(vfsStream::url("modules/fixtures2/common_no_dependencies.info.yml"));
}
-
}
/**
- * Tests composer.json file with 'drupal/core' specified.
+ * Tests composer.json file with 'drupal/core' not specified.
*
* @covers ::parse
*/
@@ -878,9 +903,7 @@ public function testComposerJsonNoDrupal() {
name: Common test
type: module
description: 'testing info file parsing'
-simple_string: 'A simple string'
version: "VERSION"
-double_colon: dummyClassName::method
COMMONTEST;
$common_json = << $common_json,
],
]);
- $this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage("The require key must at least specify a 'drupal/core' version in vfs://modules/fixtures_broken/composer.json");
+ $this->expectException(InfoParserException::class);
+ $this->expectExceptionMessage("The 'require' key must at least specify a 'drupal/core' version in vfs://modules/fixtures_broken/composer.json");
$this->infoParser->parse(vfsStream::url('modules/fixtures_broken/common_no_dependencies.info.yml'));
}
@@ -927,24 +950,26 @@ public function testInfoParserDependenciesNoCore() {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
- 'dependencies_no_core.info.txt' => $missing_composer,
+ 'dependencies_no_core.info.yml' => $missing_composer,
],
]);
$this->expectException('\Drupal\Core\Extension\InfoParserException');
- $this->expectExceptionMessage("If the 'dependencies' key is used the 'core' or 'core_version_requirement' key is required in vfs://modules/fixtures/dependencies_no_core.info.txt");
- $this->infoParser->parse(vfsStream::url('modules/fixtures/dependencies_no_core.info.txt'));
+ $this->expectExceptionMessage("If the 'dependencies' key is used, the 'core' or 'core_version_requirement' key is required in vfs://modules/fixtures/dependencies_no_core.info.yml");
+ $this->infoParser->parse(vfsStream::url('modules/fixtures/dependencies_no_core.info.yml'));
}
/**
- * Adds a composer.json file to the fixtures.
+ * Conditionally adds a composer.json file to the fixtures.
*
- * @param bool $create_composer_json
+ * @param bool $add_composer_json
* Whether the composer.json file should be created.
* @param array $fixtures
* The existing test fixtures.
+ *
+ * @see Drupal\Tests\Core\Extension\InfoParserUnitTest::assertComposerJsonIgnored()
*/
- private function addIgnoredComposerJson($create_composer_json, &$fixtures) {
- if (!$create_composer_json) {
+ private function addIgnoredComposerJson($add_composer_json, &$fixtures) {
+ if (!$add_composer_json) {
return;
}
$fixtures['composer.json'] = <<