diff --git a/core/modules/comment/src/Tests/CommentUninstallTest.php b/core/modules/comment/src/Tests/CommentUninstallTest.php index e48c312..fa97f74 100644 --- a/core/modules/comment/src/Tests/CommentUninstallTest.php +++ b/core/modules/comment/src/Tests/CommentUninstallTest.php @@ -50,7 +50,7 @@ function testCommentUninstallWithField() { try { $this->container->get('module_installer')->uninstall(array('comment')); $this->fail("Expected an exception when uninstall was attempted."); - } + } catch (ModuleUninstallValidatorException $e) { $this->pass("Caught an exception when uninstall was attempted."); } @@ -70,6 +70,16 @@ function testCommentUninstallWithoutField() { $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); $this->assertNull($field_storage, 'The comment_body field has been deleted.'); + // Manually delete the comment field on the node before module uninstallation. + $field_storage = FieldStorageConfig::loadByName('node', 'comment'); + $this->assertNotNull($field_storage, 'The comment field exists.'); + $field_storage->delete(); + + // Check that the field is now deleted. + $field_storage = FieldStorageConfig::loadByName('node', 'comment'); + $this->assertNull($field_storage, 'The comment field has been deleted.'); + + field_purge_batch(10); // Ensure that uninstallation succeeds even if the field has already been // deleted manually beforehand. $this->container->get('module_installer')->uninstall(array('comment')); diff --git a/core/modules/config/src/Tests/ConfigImportAllTest.php b/core/modules/config/src/Tests/ConfigImportAllTest.php index 7645847..0cedbfd 100644 --- a/core/modules/config/src/Tests/ConfigImportAllTest.php +++ b/core/modules/config/src/Tests/ConfigImportAllTest.php @@ -108,6 +108,12 @@ public function testInstallUninstall() { // Can not uninstall config and use admin/config/development/configuration! unset($modules_to_uninstall['config']); + // Can not uninstall editor and its dependencies as it provides filter plugins. + unset($modules_to_uninstall['editor']); + unset($modules_to_uninstall['filter']); + unset($modules_to_uninstall['file']); + unset($modules_to_uninstall['field']); + $this->assertTrue(isset($modules_to_uninstall['comment']), 'The comment module will be disabled'); // Uninstall all modules that can be uninstalled. diff --git a/core/modules/forum/src/Tests/ForumUninstallTest.php b/core/modules/forum/src/Tests/ForumUninstallTest.php index 13ebaab..e583639 100644 --- a/core/modules/forum/src/Tests/ForumUninstallTest.php +++ b/core/modules/forum/src/Tests/ForumUninstallTest.php @@ -74,7 +74,7 @@ public function testForumUninstallWithField() { $this->drupalGet('admin/modules/uninstall'); // Assert forum is required. $this->assertNoFieldByName('uninstall[forum]'); - $this->assertText('To uninstall Forum first delete all Forum content'); + $this->assertText('To uninstall Forum first delete all'); // Delete the node. $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete')); @@ -83,7 +83,7 @@ public function testForumUninstallWithField() { $this->drupalGet('admin/modules/uninstall'); // Assert forum is still required. $this->assertNoFieldByName('uninstall[forum]'); - $this->assertText('To uninstall Forum first delete all Forums terms'); + $this->assertText('To uninstall Forum first delete all'); // Delete any forum terms. $vid = $this->config('forum.settings')->get('vocabulary'); diff --git a/core/modules/system/src/Tests/System/InfoAlterTest.php b/core/modules/system/src/Tests/System/InfoAlterTest.php index 02cdd17..2af3d05 100644 --- a/core/modules/system/src/Tests/System/InfoAlterTest.php +++ b/core/modules/system/src/Tests/System/InfoAlterTest.php @@ -26,15 +26,15 @@ class InfoAlterTest extends KernelTestBase { * return freshly altered info. */ function testSystemInfoAlter() { - \Drupal::state()->set('module_test.hook_system_info_alter', TRUE); + \Drupal::state()->set('module_required_test.hook_system_info_alter', TRUE); $info = system_rebuild_module_data(); - $this->assertFalse(isset($info['node']->info['required']), 'Before the module_test is installed the node module is not required.'); + $this->assertFalse(isset($info['node']->info['required']), 'Before the module_required_test is installed the node module is not required.'); // Enable the test module. - \Drupal::service('module_installer')->install(array('module_test'), FALSE); - $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_test'), 'Test module is enabled.'); + \Drupal::service('module_installer')->install(array('module_required_test'), FALSE); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_required_test'), 'Test required module is enabled.'); $info = system_rebuild_module_data(); - $this->assertTrue($info['node']->info['required'], 'After the module_test is installed the node module is required.'); + $this->assertTrue($info['node']->info['required'], 'After the module_required_test is installed the node module is required.'); } } diff --git a/core/modules/system/tests/modules/module_required_test/module_required_test.info.yml b/core/modules/system/tests/modules/module_required_test/module_required_test.info.yml new file mode 100644 index 0000000..f424d95 --- /dev/null +++ b/core/modules/system/tests/modules/module_required_test/module_required_test.info.yml @@ -0,0 +1,11 @@ +name: 'Module required test' +type: module +description: 'Support module for module system testing.' +package: Testing +version: VERSION +core: 8.x +# Depends on the Node module to test making a module required using +# hook_system_info_alter() and ensuring that its dependencies also become +# required. +dependencies: + - drupal:node (>=8.x) diff --git a/core/modules/system/tests/modules/module_required_test/module_required_test.module b/core/modules/system/tests/modules/module_required_test/module_required_test.module new file mode 100644 index 0000000..fbb6f10 --- /dev/null +++ b/core/modules/system/tests/modules/module_required_test/module_required_test.module @@ -0,0 +1,15 @@ +getName() == 'module_required_test' && \Drupal::state()->get('module_required_test.hook_system_info_alter')) { + $info['required'] = TRUE; + $info['explanation'] = 'Testing hook_system_info_alter()'; + } +} diff --git a/core/modules/system/tests/modules/module_test/module_test.info.yml b/core/modules/system/tests/modules/module_test/module_test.info.yml index 241c3ad..5c63da2 100644 --- a/core/modules/system/tests/modules/module_test/module_test.info.yml +++ b/core/modules/system/tests/modules/module_test/module_test.info.yml @@ -4,8 +4,3 @@ description: 'Support module for module system testing.' package: Testing version: VERSION core: 8.x -# Depends on the Node module to test making a module required using -# hook_system_info_alter() and ensuring that its dependencies also become -# required. -dependencies: - - drupal:node (>=8.x) diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index 92f038b..cead329 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -49,10 +49,6 @@ function module_test_system_info_alter(&$info, Extension $file, $type) { if ($file->getName() == 'seven' && $type == 'theme') { $info['regions']['test_region'] = t('Test region'); } - if ($file->getName() == 'module_test' && \Drupal::state()->get('module_test.hook_system_info_alter')) { - $info['required'] = TRUE; - $info['explanation'] = 'Testing hook_system_info_alter()'; - } } /** diff --git a/core/profiles/standard/src/Tests/StandardTest.php b/core/profiles/standard/src/Tests/StandardTest.php index 2171765..fc41818 100644 --- a/core/profiles/standard/src/Tests/StandardTest.php +++ b/core/profiles/standard/src/Tests/StandardTest.php @@ -117,17 +117,6 @@ function testStandard() { $this->assertConfigSchema($typed_config, $name, $config->get()); } - // Ensure that configuration from the Standard profile is not reused when - // enabling a module again since it contains configuration that can not be - // installed. For example, editor.editor.basic_html is editor configuration - // that depends on the ckeditor module. The ckeditor module can not be - // installed before the editor module since it depends on the editor module. - // The installer does not have this limitation since it ensures that all of - // the install profiles dependencies are installed before creating the - // editor configuration. - \Drupal::service('module_installer')->uninstall(array('editor', 'ckeditor')); - $this->rebuildContainer(); - \Drupal::service('module_installer')->install(array('editor')); /** @var \Drupal\contact\ContactFormInterface $contact_form */ $contact_form = ContactForm::load('feedback'); $recipients = $contact_form->getRecipients();