diff --git a/core/lib/Drupal/Component/Version/DrupalSemver.php b/core/lib/Drupal/Component/Version/DrupalSemver.php index 74cdd7be70..bfce92e17a 100644 --- a/core/lib/Drupal/Component/Version/DrupalSemver.php +++ b/core/lib/Drupal/Component/Version/DrupalSemver.php @@ -21,7 +21,7 @@ class DrupalSemver { * The constraints. * * @return bool - * TRUE if the version satisfies the constraints. + * TRUE if the version satisfies the constraints, otherwise FALSE. * * @see \Composer\Semver\Semver::satisfies() */ diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index b787bd4c02..806966f9c5 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -35,14 +35,14 @@ public function parse($filename) { throw new InfoParserException("The 'core' or the 'core_dependency' key must be present in " . $filename); } if (isset($parsed_info['core']) && !preg_match("/^\d\.x$/", $parsed_info['core'])) { - throw new InfoParserException("The {$parsed_info['core']} is not valid value for 'core' in " . $filename); + throw new InfoParserException("Invalid 'core' value \"{$parsed_info['core']}\" in " . $filename); } if (isset($parsed_info['core_dependency'])) { $supports_pre_core_dependency_version = $this->isConstraintSatisfiedByPreCoreDependencyCoreVersion($parsed_info['core_dependency']); // If the 'core_dependency' constraint does not satisfy any Drupal 8 - // versions before 8.7.7 then the 'core' cannot be set or it will - // effectively support all version of Drupal 8 because 'core_dependency' - // will be ignored. + // versions before 8.7.7 then 'core' cannot be set or it will + // effectively support all versions of Drupal 8 because + // 'core_dependency' will be ignored in previous versions. if (!$supports_pre_core_dependency_version && isset($parsed_info['core'])) { throw new InfoParserException("The 'core_dependency' constraint ({$parsed_info['core_dependency']}) requires the 'core' not be set in " . $filename); } diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index c9cb79c6ad..19746f1da6 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -108,25 +108,25 @@ public function testInfoParserMissingKeys() { * @covers ::parse */ public function testMissingCoreCoreDependency() { - $missing_keys = << [ - 'missing_keys.info.txt' => $missing_keys, + 'missing_core_and_core_dependency.info.txt' => $missing_core_and_core_dependency, ], ]); - $filename = vfsStream::url('modules/fixtures/missing_keys.info.txt'); + $filename = vfsStream::url('modules/fixtures/missing_core_and_core_dependency.info.txt'); $this->expectException('\Drupal\Core\Extension\InfoParserException'); - $this->expectExceptionMessage("The 'core' or the 'core_dependency' key must be present in vfs://modules/fixtures/missing_keys.info.txt"); + $this->expectExceptionMessage("The 'core' or the 'core_dependency' key must be present in vfs://modules/fixtures/missing_core_and_core_dependency.info.txt"); $this->infoParser->parse($filename); } @@ -136,24 +136,24 @@ public function testMissingCoreCoreDependency() { * @covers ::parse */ public function testCoreDependency88() { - $core_and_core_dependency = << [ - 'core_and_core_dependency.info.txt' => $core_and_core_dependency, + 'core_dependency.info.txt' => $core_dependency, ], ]); - $filename = vfsStream::url('modules/fixtures/core_and_core_dependency.info.txt'); + $filename = vfsStream::url('modules/fixtures/core_dependency.info.txt'); $info_values = $this->infoParser->parse($filename); $this->assertSame($info_values['core_dependency'], '^8.8'); } @@ -164,17 +164,17 @@ public function testCoreDependency88() { * @covers ::parse */ public function testCoreCoreDependency88() { - $core_and_core_dependency_88 = << [ - 'missing_key.info.txt' => $missing_key, + 'invalid_core.info.txt' => $invalid_core, ], ]); - $filename = vfsStream::url('modules/fixtures/missing_key.info.txt'); + $filename = vfsStream::url('modules/fixtures/invalid_core.info.txt'); $this->expectException('\Drupal\Core\Extension\InfoParserException'); - $this->expectExceptionMessage('Missing required keys (type) in vfs://modules/fixtures/missing_key.info.txt'); + $this->expectExceptionMessage("Invalid 'core' value \"^8\" in vfs://modules/fixtures/invalid_core.info.txt"); $this->infoParser->parse($filename); } @@ -223,27 +225,56 @@ public function testInfoParserMissingKey() { * @covers ::parse */ public function testCoreDependencyInvalid() { - $core_dependency_invalid = << [ + 'invalid_core_dependency.info.txt' => $invalid_core_dependency, + ], + ]); + $filename = vfsStream::url('modules/fixtures/invalid_core_dependency.info.txt'); + $this->expectException('\Drupal\Core\Extension\InfoParserException'); + $this->expectExceptionMessage("The 'core_dependency' can not be used to specify compatibility specific version before 8.7.7 in vfs://modules/fixtures/invalid_core_dependency.info.txt"); + $this->infoParser->parse($filename); + } + + /** + * Tests that missing required key is detected. + * + * @covers ::parse + */ + public function testInfoParserMissingKey() { + $missing_key = << [ - 'core_dependency_invalid.info.txt' => $core_dependency_invalid, + 'missing_key.info.txt' => $missing_key, ], ]); - $filename = vfsStream::url('modules/fixtures/core_dependency_invalid.info.txt'); + $filename = vfsStream::url('modules/fixtures/missing_key.info.txt'); $this->expectException('\Drupal\Core\Extension\InfoParserException'); - $this->expectExceptionMessage("The 'core_dependency' can not be used to specify compatibility specific version before 8.7.7 in vfs://modules/fixtures/core_dependency_invalid.info.txt"); + $this->expectExceptionMessage('Missing required keys (type) in vfs://modules/fixtures/missing_key.info.txt'); $this->infoParser->parse($filename); }