diff --git a/core/includes/install.inc b/core/includes/install.inc index 02f8f7e169..e6db8eb8f0 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -1154,7 +1154,7 @@ function install_profile_info($profile, $langcode = 'en') { $info['dependencies'] = array_map($dependency_name_function, $info['dependencies']); } // Convert install key in [project:module] format. - $info['install'] = array_map(function($dependency) { + $info['install'] = array_map(function ($dependency) { if (strpos($dependency, ':') !== FALSE) { list(, $dependency) = explode(':', $dependency); } diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 5e24658844..4e57072112 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -106,7 +106,7 @@ protected function parseComposerFile($filename) { throw new InfoParserException("Unable to parse $filename " . json_last_error_msg()); } if (empty($parsed_info['require']['drupal/drupal'])) { - throw new InfoParserException("The require key must at least specific a 'drupal/drupal' version $filename"); + throw new InfoParserException("The require key must at least specify a 'drupal/drupal' version in $filename"); } // @todo Actually handle core constraints // https://www.drupal.org/project/drupal/issues/2313917. diff --git a/core/modules/system/tests/modules/composer_dependencies_test/composer.json b/core/modules/system/tests/modules/composer_dependencies_test/composer.json index f0621fa3d8..3efd5810f4 100644 --- a/core/modules/system/tests/modules/composer_dependencies_test/composer.json +++ b/core/modules/system/tests/modules/composer_dependencies_test/composer.json @@ -3,6 +3,6 @@ "type": "drupal-module", "require": { "drupal/drupal": "^8", - "drupal/common_test": "~2.4.2" + "drupal/common_test": "^2.4.2" } } diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php index 52e4160cda..030bf75dee 100644 --- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php +++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php @@ -70,7 +70,7 @@ public function testModulesListFormWithInvalidInfoFile() { // Confirm that the error message is shown. $this->assertSession() - ->pageTextContains('Modules could not be listed due to an error: Missing required keys (core) in ' . $path . '/broken.info.yml'); + ->pageTextContains("Modules could not be listed due to an error: If the 'core' key is not provided a composer.json file is required in " . $path . '/broken.info.yml'); // Check that the module filter text box is available. $this->assertTrue($this->xpath('//input[@name="text"]')); diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index 1f7aa7b9d4..8243df8ca3 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -214,89 +214,88 @@ public function testInfoParserCommonInfo() { } /** - * Tests composer json file. + * Tests a composer.json file. * * @covers ::parse */ - public function testInfoParserComposerJson() { - $common = << [ - 'composer.json' => $common, + 'common_no_dependencies.info.yml' => $common_info, + 'composer.json' => $common_json, ], ]); - $info_values = $this->infoParser->parse(vfsStream::url('modules/fixtures/composer.json')); + $info_values = $this->infoParser->parse(vfsStream::url('modules/fixtures/common_no_dependencies.info.yml')); + //sprint_r($info_values); $this->assertEquals('A simple string', $info_values['simple_string']); $this->assertEquals(\Drupal::VERSION, $info_values['version']); $this->assertEquals('Common test', $info_values['name']); - $this->assertEquals('common_test.admin', $info_values['configure']); - $this->assertEquals('Core', $info_values['package']); - $this->assertEquals(['field (~8.0)'], $info_values['dependencies']); - $this->assertEquals(['field' => '~8.0'], $info_values['require']); + $this->assertFalse(isset($info_values['dependencies'])); + $this->assertEquals(['field' => '~8.0'], $info_values['composer_dependencies']); $this->assertEquals('module', $info_values['type']); } /** - * Tests composer json file. + * Tests composer.json file with 'drupal/drupal' specified. * * @covers ::parse */ - public function testInfoParserComposerJsonNoDependencies() { - $common = << [ - 'composer.json' => $common, + 'fixtures_broken' => [ + 'common_no_dependencies.info.yml' => $common_info, + 'composer.json' => $common_json, ], ]); - $info_values = $this->infoParser->parse(vfsStream::url('modules/fixtures2/composer.json')); - $this->assertEquals('A simple string', $info_values['simple_string']); - $this->assertEquals(\Drupal::VERSION, $info_values['version']); - $this->assertEquals('Common test', $info_values['name']); - $this->assertEquals('common_test.admin', $info_values['configure']); - $this->assertEquals('Core', $info_values['package']); - $this->assertEquals([], $info_values['dependencies']); - $this->assertEquals([], $info_values['require']); - $this->assertEquals('module', $info_values['type']); + $this->expectException('\Drupal\Core\Extension\InfoParserException'); + $this->expectExceptionMessage("The require key must at least specify a 'drupal/drupal' version in vfs://modules/fixtures_broken/composer.json"); + $this->infoParser->parse(vfsStream::url('modules/fixtures_broken/common_no_dependencies.info.yml')); } - }