diff --git a/core/modules/system/tests/modules/system_core_incompatible_composer_test/composer.json b/core/modules/system/tests/modules/composer_core_incompatible_test/composer.json similarity index 56% rename from core/modules/system/tests/modules/system_core_incompatible_composer_test/composer.json rename to core/modules/system/tests/modules/composer_core_incompatible_test/composer.json index 341a7a556e..985a012569 100644 --- a/core/modules/system/tests/modules/system_core_incompatible_composer_test/composer.json +++ b/core/modules/system/tests/modules/composer_core_incompatible_test/composer.json @@ -1,5 +1,5 @@ { - "name": "drupal/system_core_incompatible_composer_test", + "name": "drupal/composer_core_incompatible_test", "type": "drupal-module", "require": { "drupal/core": "^100" diff --git a/core/modules/system/tests/modules/system_core_incompatible_composer_test/system_core_incompatible_composer_test.info.yml b/core/modules/system/tests/modules/composer_core_incompatible_test/composer_core_incompatible_test.info.yml similarity index 100% rename from core/modules/system/tests/modules/system_core_incompatible_composer_test/system_core_incompatible_composer_test.info.yml rename to core/modules/system/tests/modules/composer_core_incompatible_test/composer_core_incompatible_test.info.yml diff --git a/core/modules/system/tests/modules/composer_incompatible_core_composer_depend_test/composer.json b/core/modules/system/tests/modules/composer_incompatible_core_composer_depend_test/composer.json new file mode 100644 index 0000000000..8c32cc7a87 --- /dev/null +++ b/core/modules/system/tests/modules/composer_incompatible_core_composer_depend_test/composer.json @@ -0,0 +1,8 @@ +{ + "name": "drupal/composer_incompatible_core_composer_depend_test", + "type": "drupal-module", + "require": { + "drupal/core": "^8.8", + "drupal/composer_core_incompatible_test": "*" + } +} diff --git a/core/modules/system/tests/modules/composer_incompatible_core_composer_depend_test/composer_incompatible_core_composer_depend_test.info.yml b/core/modules/system/tests/modules/composer_incompatible_core_composer_depend_test/composer_incompatible_core_composer_depend_test.info.yml new file mode 100644 index 0000000000..72d70ff4d7 --- /dev/null +++ b/core/modules/system/tests/modules/composer_incompatible_core_composer_depend_test/composer_incompatible_core_composer_depend_test.info.yml @@ -0,0 +1,5 @@ +name: 'Composer.json Incompatible core version composer dependencies test' +type: module +description: 'Support module for testing system dependencies.' +package: Testing +version: VERSION diff --git a/core/modules/system/tests/modules/composer_incompatible_core_depend_test/composer.json b/core/modules/system/tests/modules/composer_incompatible_core_depend_test/composer.json new file mode 100644 index 0000000000..6b8a4532a6 --- /dev/null +++ b/core/modules/system/tests/modules/composer_incompatible_core_depend_test/composer.json @@ -0,0 +1,8 @@ +{ + "name": "drupal/composer_incompatible_core_depend_test", + "type": "drupal-module", + "require": { + "drupal/core": "^8.8", + "drupal/system_incompatible_core_version_test": "*" + } +} diff --git a/core/modules/system/tests/modules/composer_incompatible_core_depend_test/composer_incompatible_core_depend_test.info.yml b/core/modules/system/tests/modules/composer_incompatible_core_depend_test/composer_incompatible_core_depend_test.info.yml new file mode 100644 index 0000000000..571e9257e5 --- /dev/null +++ b/core/modules/system/tests/modules/composer_incompatible_core_depend_test/composer_incompatible_core_depend_test.info.yml @@ -0,0 +1,5 @@ +name: 'Composer.json Incompatible core version dependencies test' +type: module +description: 'Support module for testing system dependencies.' +package: Testing +version: VERSION diff --git a/core/modules/system/tests/modules/composer_incompatible_module_version_dependencies_test/composer.json b/core/modules/system/tests/modules/composer_incompatible_module_version_dependencies_test/composer.json new file mode 100644 index 0000000000..a04dbb51d5 --- /dev/null +++ b/core/modules/system/tests/modules/composer_incompatible_module_version_dependencies_test/composer.json @@ -0,0 +1,8 @@ +{ + "name": "drupal/composer_incompatible_module_version_dependencies_test", + "type": "drupal-module", + "require": { + "drupal/core": "^8.8", + "drupal/system_incompatible_module_version_test": "^2" + } +} diff --git a/core/modules/system/tests/modules/composer_incompatible_module_version_dependencies_test/composer_incompatible_module_version_dependencies_test.info.yml b/core/modules/system/tests/modules/composer_incompatible_module_version_dependencies_test/composer_incompatible_module_version_dependencies_test.info.yml new file mode 100644 index 0000000000..6b544da404 --- /dev/null +++ b/core/modules/system/tests/modules/composer_incompatible_module_version_dependencies_test/composer_incompatible_module_version_dependencies_test.info.yml @@ -0,0 +1,5 @@ +name: 'Incompatible module version dependencies test using composer' +type: module +description: 'Support module for testing system dependencies using composer.' +package: Testing +version: VERSION diff --git a/core/modules/system/tests/modules/system_incompatible_core_composer_depend_test/system_incompatible_core_composer_depend_test.info.yml b/core/modules/system/tests/modules/system_incompatible_core_composer_depend_test/system_incompatible_core_composer_depend_test.info.yml new file mode 100644 index 0000000000..ffee1eeb33 --- /dev/null +++ b/core/modules/system/tests/modules/system_incompatible_core_composer_depend_test/system_incompatible_core_composer_depend_test.info.yml @@ -0,0 +1,8 @@ +name: 'System incompatible core version dependencies using composer.json test' +type: module +description: 'Support module for testing system dependencies.' +package: Testing +version: VERSION +core: 8.x +dependencies: + - drupal:composer_core_incompatible_test diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php index 0dad822e89..ffde911ed2 100644 --- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php +++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php @@ -70,35 +70,50 @@ public function testMissingModules() { * Tests enabling a module that depends on an incompatible version of a module. */ public function testIncompatibleModuleVersionDependency() { - // Test that the system_incompatible_module_version_dependencies_test is - // marked as having an incompatible dependency. - // @todo Add a composer.json test case. + $assert_session = $this->assertSession(); $this->drupalGet('admin/modules'); + // Test that the system_incompatible_module_version_dependencies_test which + // uses an info.yml file for dependencies is marked as having an + // incompatible dependency. $this->assertRaw(t('@module (incompatible with version @version)', [ '@module' => 'System incompatible module version test (>2.0)', '@version' => '1.0', ]), 'A module that depends on an incompatible version of a module is marked as such.'); - $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_module_version_dependencies_test][enable]"]'); - $this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.'); + $assert_session->fieldDisabled('modules[system_incompatible_module_version_dependencies_test][enable]'); + // Test that the composer_incompatible_module_version_dependencies_test + // which uses a composer.yml file for dependencies is marked as having an + // incompatible dependency. + $assert_session->responseContains('System incompatible module version test (^2) (incompatible with version 1.0)'); + $assert_session->fieldDisabled('modules[composer_incompatible_module_version_dependencies_test][enable]'); + } /** * Tests enabling a module that depends on a module with an incompatible core version. */ public function testIncompatibleCoreVersionDependency() { - // Test that the system_incompatible_core_version_dependencies_test is - // marked as having an incompatible dependency. $assert_session = $this->assertSession(); $this->drupalGet('admin/modules'); - $this->assertRaw(t('@module (incompatible with this version of Drupal core)', [ - '@module' => 'System incompatible core version test', - ]), 'A module that depends on a module with an incompatible core version is marked as such.'); + // Test that module using an info.yml file with a dependency that is using a + // info.yml with a incompatible core version is marked as having an + // incompatible dependency. + $assert_session->elementContains('css', '#edit-modules-system-incompatible-core-version-dependencies-test-enable-description', 'System incompatible core version test (incompatible with this version of Drupal core)'); $assert_session->fieldDisabled('modules[system_incompatible_core_version_dependencies_test][enable]'); - // @todo Add test cases - // 1. info.yml dependent on module with composer.json with incomppatible core - // 2. composer.json dependent on module with info.yml with incompatible core. - // 3. composer.json dependent on module with composer.josn with incompatible core. - + // Test that module using an composer.json file with a dependency that is + // using a info.yml with a incompatible core version is marked as having an + // incompatible dependency. + $assert_session->elementContains('css', '#edit-modules-composer-incompatible-core-depend-test-enable-description', 'System incompatible core version test (incompatible with this version of Drupal core)'); + $assert_session->fieldDisabled('modules[composer_incompatible_core_depend_test][enable]'); + // Test that module using an info.yml file with a dependency that is using a + // composer.json with a incompatible core version is marked as having an + // incompatible dependency. + $assert_session->elementContains('css', '#edit-modules-system-incompatible-core-composer-depend-test-enable-description', 'System core incompatible composer.json test (incompatible with this version of Drupal core)'); + $assert_session->fieldDisabled('modules[composer_incompatible_core_composer_depend_test][enable]'); + // Test that module using an composer.json file with a dependency that is + // using a composer.json with a incompatible core version is marked as + // having an incompatible dependency. + $assert_session->elementContains('css', '#edit-modules-composer-incompatible-core-composer-depend-test-enable-description', 'System core incompatible composer.json test (incompatible with this version of Drupal core)'); + $assert_session->fieldDisabled('modules[composer_incompatible_core_composer_depend_test][enable]'); } /** @@ -121,7 +136,7 @@ public function testCoreCompatibility() { $this->drupalGet('admin/modules'); $assert_session->fieldDisabled('modules[system_incompatible_core_version_test_1x][enable]'); $assert_session->fieldDisabled('modules[system_core_incompatible_semver_test][enable]'); - $assert_session->fieldDisabled('modules[system_core_incompatible_composer_test][enable]'); + $assert_session->fieldDisabled('modules[composer_core_incompatible_test][enable]'); // Test compatible 'core_version_requirement' and compatible 'core'. $this->drupalGet('admin/modules'); diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php index d6eb41e593..1ee5c6ed29 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php @@ -119,11 +119,11 @@ public function providerTestInvalidCoreInstall() { 'system_core_incompatible_semver_test', TRUE, ], - 'no dependencies system_core_incompatible_composer_test' => [ + 'no dependencies composer_core_incompatible_test' => [ 'system_core_incompatible_semver_test', FALSE, ], - 'install_dependencies system_core_incompatible_composer_test' => [ + 'install_dependencies composer_core_incompatible_test' => [ 'system_core_incompatible_semver_test', TRUE, ], @@ -133,23 +133,67 @@ public function providerTestInvalidCoreInstall() { /** * Tests install with a dependency with an invalid core version constraint. * + * @dataProvider providerDependencyInvalidCoreInstall * @covers ::install */ - public function testDependencyInvalidCoreInstall() { - // @todo Add dataProvider with a composer.json test case. + public function testDependencyInvalidCoreInstall($module, $dependency) { $this->expectException(MissingDependencyException::class); - $this->expectExceptionMessage("Unable to install modules: module 'system_incompatible_core_version_dependencies_test'. Its dependency module 'system_incompatible_core_version_test' is incompatible with this version of Drupal core."); - $this->container->get('module_installer')->install(['system_incompatible_core_version_dependencies_test']); + $this->expectExceptionMessage("Unable to install modules: module '$module'. Its dependency module '$dependency' is incompatible with this version of Drupal core."); + $this->container->get('module_installer')->install([$module]); + } + + /** + * Dataprovider for testDependencyInvalidCoreInstall(). + */ + public function providerDependencyInvalidCoreInstall() { + return [ + 'info with info dependency' => [ + 'system_incompatible_core_version_dependencies_test', + 'system_incompatible_core_version_test', + ], + 'composer.json with info dependency' => [ + 'composer_incompatible_core_depend_test', + 'system_incompatible_core_version_test', + ], + 'composer.json with composer.json dependency' => [ + 'composer_incompatible_core_composer_depend_test', + 'composer_core_incompatible_test', + ], + 'info with composer.json dependency' => [ + 'composer_incompatible_core_composer_depend_test', + 'composer_core_incompatible_test', + ], + ]; } /** * Tests no dependencies install with a dependency with invalid core. * + * @dataProvider provideDependencyInvalidCoreInstallNoDependencies * @covers ::install */ - public function testDependencyInvalidCoreInstallNoDependencies() { - // @todo Add a composer.json test case. - $this->assertTrue($this->container->get('module_installer')->install(['system_incompatible_core_version_dependencies_test'], FALSE)); + public function testDependencyInvalidCoreInstallNoDependencies($module) { + $this->assertTrue($this->container->get('module_installer')->install([$module], FALSE)); + } + + /** + * Dataprovider for testDependencyInvalidCoreInstallNoDependencies(). + */ + public function provideDependencyInvalidCoreInstallNoDependencies() { + return [ + 'info with info dependency' => [ + 'system_incompatible_core_version_dependencies_test', + ], + 'composer.json with info dependency' => [ + 'composer_incompatible_core_depend_test', + ], + 'composer.json with composer.json dependency' => [ + 'composer_incompatible_core_composer_depend_test', + ], + 'info with composer.json dependency' => [ + 'composer_incompatible_core_composer_depend_test', + ], + ]; } }