diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php index f042911..70fe125 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php @@ -147,30 +147,44 @@ public function buildForm(array $form, array &$form_state) { $form['entities'] = array( '#type' => 'details', - '#title' => $this->t('Further information'), - '#description' => $this->t('The listed entities will be deleted.'), + '#title' => $this->t('Configuration deletions'), + '#description' => $this->t('The listed configuration will be deleted.'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#access' => FALSE, ); // Get the dependent entities. + $entity_types = array(); $dependent_entities = $this->configManager->findConfigEntityDependentsAsEntities('module', $this->modules); - if (!empty($dependent_entities)) { - $form['entities']['#access'] = TRUE; - } foreach ($dependent_entities as $entity) { $entity_type_id = $entity->getEntityTypeId(); if (!isset($form['entities'][$entity_type_id])) { $entity_type = $this->entityManager->getDefinition($entity_type_id); + // Store the ID and label to sort the entity types and entities later. + $label = $entity_type->getLabel(); + $entity_types[$entity_type_id] = $label; $form['entities'][$entity_type_id] = array( '#theme' => 'item_list', - '#title' => $entity_type->getLabel(), + '#title' => $label, '#items' => array(), ); } $form['entities'][$entity_type_id]['#items'][] = $entity->label(); } + if (!empty($dependent_entities)) { + $form['entities']['#access'] = TRUE; + + // Add a weight key to the entity type sections. + asort($entity_types, SORT_FLAG_CASE); + $weight = 0; + foreach ($entity_types as $entity_type_id => $label) { + $form['entities'][$entity_type_id]['#weight'] = $weight; + // Sort the list of entity labels alphabetically. + sort($form['entities'][$entity_type_id]['#items'], SORT_FLAG_CASE); + $weight++; + } + } return parent::buildForm($form, $form_state); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php index 2f6443e..bbb4399 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Module; +use Drupal\Component\Utility\String; use Drupal\simpletest\WebTestBase; /** @@ -19,7 +20,7 @@ class UninstallTest extends WebTestBase { * * @var array */ - public static $modules = array('module_test', 'user'); + public static $modules = array('module_test', 'user', 'views', 'node'); public static function getInfo() { return array( @@ -42,12 +43,44 @@ function testUserPermsUninstalled() { } /** - * Tests the Uninstall page. + * Tests the Uninstall page and Uninstall confirmation page. */ function testUninstallPage() { $account = $this->drupalCreateUser(array('administer modules')); $this->drupalLogin($account); $this->drupalGet('admin/modules/uninstall'); $this->assertTitle(t('Uninstall') . ' | Drupal'); + + // Uninstall module_test. + $edit = array(); + $edit['uninstall[module_test]'] = TRUE; + $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall')); + $this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.'); + $this->drupalPostForm(NULL, NULL, t('Uninstall')); + $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.'); + + // Uninstall node testing that the configuration that will be deleted is + // listed. + $node_dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('module', array('node')); + $edit = array(); + $edit['uninstall[node]'] = TRUE; + $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall')); + $this->assertText(\Drupal::translation()->translate('Configuration deletions'), 'Configuration deletions listed on the module install confirmation page.'); + + $entity_types = array(); + foreach ($node_dependencies as $entity) { + $label = $entity->label(); + $this->assertText($label, String::format('The entity label "!label" found.', array('!label' => $label))); + $entity_types[] = $entity->getEntityTypeId(); + } + $entity_types = array_unique($entity_types); + foreach ($entity_types as $entity_type_id) { + $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + // Add h3's since the entity type label is often repeated in the entity + // labels. + $this->assertRaw('

' . $entity_type->getLabel() . '

'); + } + $this->drupalPostForm(NULL, NULL, t('Uninstall')); + $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.'); } } diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php index a5c7ec9..d5a4be1 100644 --- a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php +++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php @@ -160,7 +160,7 @@ public function testTourFunctionality() { // Ensure that a tour entity has the expected dependencies based on plugin // providers and the module named in the configuration entity. $dependencies = $tour->calculateDependencies(); - $this->assertEqual($dependencies['module'], array('tour_test', 'system')); + $this->assertEqual($dependencies['module'], array('system', 'tour_test')); $this->drupalGet('tour-test-1');