View source
<?php
namespace Drupal\Tests\thunder\Functional;
class ModuleUninstallTest extends ThunderTestBase {
protected static $moduleLists = [
[
'thunder_riddle',
],
[
'media_riddle_marketplace',
],
[
'riddle_marketplace',
],
[
'thunder_riddle',
'media_riddle_marketplace',
'riddle_marketplace',
],
[
'thunder_liveblog',
],
[
'liveblog_pusher',
'liveblog',
'simple_gmap',
],
[
'thunder_liveblog',
'liveblog_pusher',
'liveblog',
'simple_gmap',
],
[
'diff',
],
[
'content_lock',
],
[
'adsense',
],
[
'google_analytics',
],
[
'access_unpublished',
],
[
'responsive_preview',
],
[
'shariff',
],
[
'length_indicator',
],
[
'redirect',
],
[
'simple_sitemap',
],
];
protected function installModules(array $modules = []) {
if ($modules) {
$success = $this->container
->get('module_installer')
->install($modules, TRUE);
$this
->assertTrue($success);
$this
->rebuildContainer();
}
}
protected function uninstallModules(array $modules = []) {
if ($modules) {
$success = $this->container
->get('module_installer')
->uninstall($modules, TRUE);
$this
->assertTrue($success);
$this
->rebuildContainer();
}
}
public function testModules() {
$uninstallFailures = [];
foreach (static::$moduleLists as $modules) {
try {
$this
->installModules($modules);
$this
->uninstallModules($modules);
$this
->installModules($modules);
} catch (\Exception $e) {
$uninstallFailures[] = [
'modules' => $modules,
'error' => $e
->getMessage(),
];
}
}
if ($uninstallFailures) {
throw new \Exception(print_r($uninstallFailures, TRUE));
}
}
}