diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index 7acc0fd..e1e0e58 100644 --- a/core/lib/Drupal/Core/Extension/module.api.php +++ b/core/lib/Drupal/Core/Extension/module.api.php @@ -748,7 +748,8 @@ function hook_updater_info_alter(&$updaters) { * - value: The current value (e.g., version, time, level, etc). During * install phase, this should only be used for version numbers, do not set * it if not applicable. - * - description: The description of the requirement/status. + * - description: The description of the requirement/status. May be either a + * string or a render array. * - severity: The requirement's result/severity level, one of: * - REQUIREMENT_INFO: For info only. * - REQUIREMENT_OK: The requirement is satisfied. diff --git a/core/modules/system/src/Tests/Module/HookRequirementsOutputTest.php b/core/modules/system/src/Tests/Module/HookRequirementsOutputTest.php new file mode 100644 index 0000000..72ccaea --- /dev/null +++ b/core/modules/system/src/Tests/Module/HookRequirementsOutputTest.php @@ -0,0 +1,50 @@ +drupalCreateUser(array('access administration pages', 'administer site configuration')); + $this->drupalLogin($admin_user); + } + + /** + * Tests the hook output with both a string and render array. + * + * @todo We should possibly test both the install and runtime phases. + */ + function testHookRequirementsOutput() { + \Drupal::state()->set('requirements3_test.description_array', FALSE); + $this->drupalGet('admin/reports/status'); + $this->assertText(t('Requirements 3 Test')); + $this->assertText(t('Requirements 3 string.')); + \Drupal::state()->set('requirements3_test.description_array', TRUE); + $this->drupalGet('admin/reports/status'); + $this->assertText(t('Requirements 3 Test')); + $this->assertText(t('Requirements list')); + $this->assertText(t('First message')); + $this->assertText(t('Second message')); + } +} diff --git a/core/modules/system/tests/modules/requirements3_test/requirements3_test.info.yml b/core/modules/system/tests/modules/requirements3_test/requirements3_test.info.yml new file mode 100644 index 0000000..b5affe8 --- /dev/null +++ b/core/modules/system/tests/modules/requirements3_test/requirements3_test.info.yml @@ -0,0 +1,6 @@ +name: 'Requirements 3 Test' +type: module +description: 'Tests output of hook_requirements().' +package: Testing +version: VERSION +core: 8.x diff --git a/core/modules/system/tests/modules/requirements3_test/requirements3_test.install b/core/modules/system/tests/modules/requirements3_test/requirements3_test.install new file mode 100644 index 0000000..f7b6d38 --- /dev/null +++ b/core/modules/system/tests/modules/requirements3_test/requirements3_test.install @@ -0,0 +1,35 @@ +get('requirements3_test.description_array')) { + $requirements['requirements3_test'] = array( + 'title' => t('Requirements 3 Test'), + 'severity' => REQUIREMENT_WARNING, + 'description' => [ + '#theme' => 'item_list', + '#title' => t('Requirements list'), + '#items' => [t('First message'), t('Second message')], + ] + ); + } + else{ + $requirements['requirements3_test'] = array( + 'title' => t('Requirements 3 Test'), + 'severity' => REQUIREMENT_WARNING, + 'description' => t('Requirements 3 string.'), + ); + } + + return $requirements; +}