function ThemeUiTest::uninstallModules

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php \Drupal\Tests\system\Functional\Theme\ThemeUiTest::uninstallModules()
  2. 10 core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php \Drupal\Tests\system\Functional\Theme\ThemeUiTest::uninstallModules()
  3. 11.x core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php \Drupal\Tests\system\Functional\Theme\ThemeUiTest::uninstallModules()

Uninstalls modules via the admin UI.

Parameters

string[] $module_names: An array of module machine names.

1 call to ThemeUiTest::uninstallModules()
ThemeUiTest::testThemeInstallWithModuleDependencies in core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php
Tests installing a theme with module dependencies.

File

core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php, line 170

Class

ThemeUiTest
Tests the theme UI.

Namespace

Drupal\Tests\system\Functional\Theme

Code

protected function uninstallModules(array $module_names) {
    $assert_session = $this->assertSession();
    $this->drupalGet('admin/modules/uninstall');
    foreach ($module_names as $attribute) {
        $assert_session->elementExists('css', "[name=\"uninstall[{$attribute}]\"]:not([disabled])");
    }
    $to_uninstall = [];
    foreach ($module_names as $attribute) {
        $to_uninstall["uninstall[{$attribute}]"] = 1;
    }
    if (!empty($to_uninstall)) {
        $this->drupalGet('admin/modules/uninstall');
        $this->submitForm($to_uninstall, 'Uninstall');
        $assert_session->pageTextContains('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!');
        $assert_session->pageTextContains('Would you like to continue with uninstalling the above?');
        foreach ($module_names as $module_name) {
            $assert_session->pageTextContains($this->testModules[$module_name]);
        }
        $this->getSession()
            ->getPage()
            ->pressButton('Uninstall');
        $assert_session->pageTextContains('The selected modules have been uninstalled.');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.