container->get('module_installer')->uninstall(['module_test']); // Are the perms defined by module_test removed? $this->assertFalse(user_roles(FALSE, 'module_test perm'), 'Permissions were all removed.'); } /** * Tests the Uninstall page and Uninstall confirmation page. */ public function testUninstallPage() { $account = $this->drupalCreateUser(['administer modules']); $this->drupalLogin($account); // Create a node type. $node_type = NodeType::create(['type' => 'uninstall_blocker', 'name' => 'Uninstall blocker']); // Create a dependency that can be fixed. $node_type->setThirdPartySetting('module_test', 'key', 'value'); $node_type->save(); // Add a node to prevent node from being uninstalled. $node = Node::create([ 'type' => 'uninstall_blocker', 'title' => $this->randomString(), ]); $node->save(); $this->drupalGet('admin/modules/uninstall'); $this->assertTitle(t('Uninstall') . ' | Drupal'); // Be sure labels are rendered properly. // @see regression https://www.drupal.org/node/2512106 $this->assertRaw(''); $this->assertText(\Drupal::translation()->translate('The following reason prevents Node from being uninstalled:')); $this->assertText(\Drupal::translation()->translate('There is content for the entity type: Content')); // Delete the node to allow node to be uninstalled. $node->delete(); // Uninstall module_test. $edit = []; $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->assertText(\Drupal::translation()->translate('Configuration updates'), 'Configuration updates listed on the module install confirmation page.'); $this->assertText($node_type->label()); $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', ['node']); $edit = []; $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.'); $this->assertNoText(\Drupal::translation()->translate('Configuration updates'), 'No configuration updates listed on the module install confirmation page.'); $entity_types = []; foreach ($node_dependencies as $entity) { $label = $entity->label() ?: $entity->id(); $this->assertText($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('