summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2016-12-07 20:27:15 (GMT)
committerxjm2016-12-07 20:27:15 (GMT)
commit37c07a737bfd935d0cd51e21acb9061accd55270 (patch)
tree6c16ddb61fe9109d56f32a1ddcb1889fd4ea80ac
parent20982963f9d847681f260493d127aa756a0a94f8 (diff)
Issue #2833462 by alexpott, tim.plunkett, Berdir: hook_requirements($phase = 'install') does not work as expected for experimental modules
-rw-r--r--core/modules/system/src/Form/ModulesListForm.php1
-rw-r--r--core/modules/system/src/Tests/Module/ExperimentalModuleTest.php8
-rw-r--r--core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.info.yml6
-rw-r--r--core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install20
-rw-r--r--core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module18
5 files changed, 53 insertions, 0 deletions
diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php
index 7831c38..e74d898 100644
--- a/core/modules/system/src/Form/ModulesListForm.php
+++ b/core/modules/system/src/Form/ModulesListForm.php
@@ -411,6 +411,7 @@ class ModulesListForm extends FormBase {
foreach (array_keys($modules['install']) as $module) {
if (!drupal_check_module($module)) {
unset($modules['install'][$module]);
+ unset($modules['experimental'][$module]);
foreach (array_keys($data[$module]->required_by) as $dependent) {
unset($modules['install'][$dependent]);
unset($modules['dependencies'][$dependent]);
diff --git a/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php b/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php
index 83af4ad..7b1a376 100644
--- a/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php
+++ b/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php
@@ -120,6 +120,14 @@ class ExperimentalModuleTest extends WebTestBase {
$this->drupalPostForm(NULL, [], 'Continue');
$this->assertText('2 modules have been enabled: Experimental Test, Experimental Dependency Test');
+ // Try to enable an experimental module that can not be due to
+ // hook_requirements().
+ \Drupal::state()->set('experimental_module_requirements_test_requirements', TRUE);
+ $edit = [];
+ $edit["modules[Core (Experimental)][experimental_module_requirements_test][enable]"] = TRUE;
+ $this->drupalPostForm('admin/modules', $edit, 'Install');
+ $this->assertUrl('admin/modules', [], 'If the module can not be installed we are not taken to the confirm form.');
+ $this->assertText('The Experimental Test Requirements module can not be installed.');
}
}
diff --git a/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.info.yml b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.info.yml
new file mode 100644
index 0000000..8ac724b
--- /dev/null
+++ b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.info.yml
@@ -0,0 +1,6 @@
+name: 'Experimental Requirements Test'
+type: module
+description: 'Module in the experimental package to test hook_requirements() with an experimental module.'
+package: Core (Experimental)
+version: VERSION
+core: 8.x
diff --git a/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install
new file mode 100644
index 0000000..1ee0dca
--- /dev/null
+++ b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.install
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * @file
+ * Experimental Test Requirements module to test hook_requirements().
+ */
+
+/**
+ * Implements hook_requirements().
+ */
+function experimental_module_requirements_test_requirements() {
+ $requirements = [];
+ if (\Drupal::state()->get('experimental_module_requirements_test_requirements', FALSE)) {
+ $requirements['experimental_module_requirements_test_requirements'] = [
+ 'severity' => REQUIREMENT_ERROR,
+ 'description' => t('The Experimental Test Requirements module can not be installed.'),
+ ];
+ }
+ return $requirements;
+}
diff --git a/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module
new file mode 100644
index 0000000..a2321aa
--- /dev/null
+++ b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module
@@ -0,0 +1,18 @@
+<?php
+
+/**
+ * @file
+ * Experimental Test Requirements module to test hook_requirements().
+ */
+
+/**
+ * Implements hook_help().
+ */
+function experimental_module_requirements_test_help($route_name) {
+ switch ($route_name) {
+ case 'help.page.experimental_module_requirements_test':
+ // Make the help text conform to core standards. See
+ // \Drupal\system\Tests\Module\InstallUninstallTest::assertHelp().
+ return t('The Experimental Requirements Test module is not done yet. It may eat your data, but you can read the <a href=":url">online documentation for the Experimental Requirements Test module</a>.', [':url' => 'http://www.example.com']);
+ }
+}