diff --git a/core/modules/system/src/Tests/Module/HookRequirementsTest.php b/core/modules/system/src/Tests/Module/HookRequirementsTest.php index a4066dd..b756a05 100644 --- a/core/modules/system/src/Tests/Module/HookRequirementsTest.php +++ b/core/modules/system/src/Tests/Module/HookRequirementsTest.php @@ -89,18 +89,17 @@ function testHookRequirements() { } /** - * Tests the result hook_requirements() to make sure that the message - * that lists "value" requirements comes after the description. + * Tests hook_requirements() message lists "value" after the description. * * @see requirements1_test_requirements() - * @see https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!module.api.php/function/hook_requirements/8 + * @see hook_requirements() */ - function testVersionRequirements() { - // First, let's make sure the test module is not installed. + public function testVersionRequirements() { + // Make sure the test module is not installed. $this->assertModules(['requirements1_test'], FALSE); - // Configure the module's hook_requirements(). Testing with - // render array on and use value on. + // Configure the module's hook_requirements(). Testing with render array on + // and use value on. \Drupal::state()->set('requirements1_test.phase', "install"); \Drupal::state()->set('requirements1_test.severity', REQUIREMENT_ERROR); \Drupal::state()->set('requirements1_test.description_array', TRUE); @@ -111,48 +110,39 @@ function testVersionRequirements() { $edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test'; $this->drupalPostForm('admin/modules', $edit, t('Install')); + // Verify the module did not install. $this->assertModules(['requirements1_test'], FALSE); - // Check that the rendered description (from a render array) is followed - // by the value string. - parent::assertText('second item (Currently using'); - $this->container->get('module_installer')->uninstall(['requirements1_test']); - $this->assertModules(['requirements1_test'], FALSE); + // Check that the rendered description (from a render array) is followed by + // the value string. + parent::assertText('second item (Currently using'); - // Configure the module's hook_requirements(). Testing with - // render array off (using a string) and use value on. + // Re-configure the module's hook_requirements(). Testing with render array + // off (using a string) and use value on. \Drupal::state()->set('requirements1_test.phase', "install"); \Drupal::state()->set('requirements1_test.severity', REQUIREMENT_ERROR); \Drupal::state()->set('requirements1_test.description_array', FALSE); \Drupal::state()->set('requirements1_test.use_value', TRUE); // Attempt to install the module. - $edit = []; - $edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test'; $this->drupalPostForm('admin/modules', $edit, t('Install')); - $this->assertModules(['requirements1_test'], FALSE); - // Check that the rendered description (from a render array) is followed - // by the value string. + + // Check that the rendered description (from a render array) is followed by + // the value string. parent::assertText('markup!. (Currently using'); - $this->container->get('module_installer')->uninstall(['requirements1_test']); - $this->assertModules(['requirements1_test'], FALSE); - // Configure the module's hook_requirements(). Testing with - // render array off and use value off. + // Re-configure the module's hook_requirements(). Testing with render array + // off and use value off. \Drupal::state()->set('requirements1_test.phase', "install"); \Drupal::state()->set('requirements1_test.severity', REQUIREMENT_ERROR); \Drupal::state()->set('requirements1_test.description_array', FALSE); \Drupal::state()->set('requirements1_test.use_value', FALSE); // Attempt to install the module. - $edit = []; - $edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test'; $this->drupalPostForm('admin/modules', $edit, t('Install')); - $this->assertModules(['requirements1_test'], FALSE); + parent::assertNoText('second item (Currently using'); parent::assertNoText('markup!. (Currently using'); - $this->container->get('module_installer')->uninstall(['requirements1_test']); - } /**