diff --git a/core/modules/system/tests/modules/system_core_composer_test/composer.json b/core/modules/system/tests/modules/system_core_composer_test/composer.json
new file mode 100644
index 0000000000..a6d34d7743
--- /dev/null
+++ b/core/modules/system/tests/modules/system_core_composer_test/composer.json
@@ -0,0 +1,7 @@
+{
+ "name": "drupal/system_core_composer_test",
+ "type": "drupal-module",
+ "require": {
+ "drupal/core": "^8.8 || ^9 || ^10 || ^11 || ^12 || ^13"
+ }
+}
diff --git a/core/modules/system/tests/modules/system_core_composer_test/system_core_composer_test.info.yml b/core/modules/system/tests/modules/system_core_composer_test/system_core_composer_test.info.yml
new file mode 100644
index 0000000000..0c56c05ecf
--- /dev/null
+++ b/core/modules/system/tests/modules/system_core_composer_test/system_core_composer_test.info.yml
@@ -0,0 +1,5 @@
+name: 'System core version test using composer.json.'
+type: module
+description: 'Support module for testing core using composer.'
+package: Testing
+version: 1.0.0
diff --git a/core/modules/system/tests/modules/system_core_incompatible_composer_test/composer.json b/core/modules/system/tests/modules/system_core_incompatible_composer_test/composer.json
new file mode 100644
index 0000000000..341a7a556e
--- /dev/null
+++ b/core/modules/system/tests/modules/system_core_incompatible_composer_test/composer.json
@@ -0,0 +1,7 @@
+{
+ "name": "drupal/system_core_incompatible_composer_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/system_core_incompatible_composer_test/system_core_incompatible_composer_test.info.yml
new file mode 100644
index 0000000000..90165e82df
--- /dev/null
+++ b/core/modules/system/tests/modules/system_core_incompatible_composer_test/system_core_incompatible_composer_test.info.yml
@@ -0,0 +1,5 @@
+name: 'System core incompatible composer.json test'
+type: module
+description: 'Support module for testing core incompatible using composer.json.'
+package: Testing
+version: 1.0.0
diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
index 0d4859ddcb..0dad822e89 100644
--- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php
+++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
@@ -32,6 +32,7 @@ public function testProjectNamespaceForDependencies() {
*/
public function testEnableWithoutDependency() {
// Attempt to enable Content Translation without Language enabled.
+ // @todo Add a composer.json test case.
$edit = [];
$edit['modules[content_translation][enable]'] = 'content_translation';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
@@ -57,12 +58,12 @@ public function testEnableWithoutDependency() {
public function testMissingModules() {
// Test that the system_dependencies_test module is marked
// as missing a dependency.
+ $assert_session = $this->assertSession();
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (missing)', ['@module' => Unicode::ucfirst('_missing_dependency')]), 'A module with missing dependencies is marked as such.');
- $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_dependencies_test][enable]"]');
+ $assert_session->fieldDisabled('modules[system_dependencies_test][enable]');
$this->assertRaw(t('@module (missing)', ['@module' => Unicode::ucfirst('missing_composer_dependency')]), 'A module with missing dependencies is marked as such.');
- $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_composer_dependencies_test][enable]"]');
- $this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
+ $assert_session->fieldDisabled('modules[system_composer_dependencies_test][enable]');
}
/**
@@ -71,6 +72,7 @@ public function testMissingModules() {
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.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (incompatible with version @version)', [
'@module' => 'System incompatible module version test (>2.0)',
@@ -86,12 +88,17 @@ public function testIncompatibleModuleVersionDependency() {
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.');
- $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_core_version_dependencies_test][enable]"]');
- $this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
+ $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.
+
}
/**
@@ -114,17 +121,20 @@ 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]');
// Test compatible 'core_version_requirement' and compatible 'core'.
$this->drupalGet('admin/modules');
$assert_session->fieldEnabled('modules[common_test][enable]');
$assert_session->fieldEnabled('modules[system_core_semver_test][enable]');
+ $assert_session->fieldEnabled('modules[system_core_composer_test][enable]');
// Ensure the modules can actually be installed.
$edit['modules[common_test][enable]'] = 'common_test';
$edit['modules[system_core_semver_test][enable]'] = 'system_core_semver_test';
+ $edit['modules[system_core_composer_test][enable]'] = 'system_core_composer_test';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
- $this->assertModules(['common_test', 'system_core_semver_test'], TRUE);
+ $this->assertModules(['common_test', 'system_core_semver_test', 'system_core_composer_test'], TRUE);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
index 8c94c70620..d6eb41e593 100644
--- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php
@@ -119,6 +119,14 @@ public function providerTestInvalidCoreInstall() {
'system_core_incompatible_semver_test',
TRUE,
],
+ 'no dependencies system_core_incompatible_composer_test' => [
+ 'system_core_incompatible_semver_test',
+ FALSE,
+ ],
+ 'install_dependencies system_core_incompatible_composer_test' => [
+ 'system_core_incompatible_semver_test',
+ TRUE,
+ ],
];
}
@@ -128,6 +136,7 @@ public function providerTestInvalidCoreInstall() {
* @covers ::install
*/
public function testDependencyInvalidCoreInstall() {
+ // @todo Add dataProvider with a composer.json test case.
$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']);
@@ -139,6 +148,7 @@ public function testDependencyInvalidCoreInstall() {
* @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));
}