$added_modules =
array_diff(array_keys($now_installed_list),
array_keys($was_installed_list));
while ($added_modules) { $initial_count =
count($added_modules);
foreach ($added_modules as $to_uninstall) { // See if we can currently uninstall this module (if its dependencies
// have been uninstalled), and do so if we can.
$this->
drupalGet('admin/modules/uninstall'
);
$checkbox =
$this->
assertSession()->
fieldExists("uninstall[
$to_uninstall]"
);
if (!
$checkbox->
hasAttribute('disabled'
)) { // This one is eligible for being uninstalled.
$package =
$all_modules[$to_uninstall]->info
['package'
];
$this->
assertSuccessfulUninstall($to_uninstall,
$package);
$added_modules =
array_diff($added_modules,
[$to_uninstall]);
} } // If we were not able to find a module to uninstall, fail and exit the
// loop.
$final_count =
count($added_modules);
if ($initial_count ==
$final_count) { $this->
fail('Remaining modules could not be uninstalled for ' .
$name);
break;
} }