Issue #2474363 by Aki Tendo, alexpott, Dom., MattA, dawehner, TR, hass, Wim Leers, cburschka, Berdir: Stuck in failed module install process
parent
2d9e1c5a2d
commit
7d71cb2a26
|
@ -84,7 +84,7 @@ class ModulesUninstallForm extends FormBase {
|
||||||
// Get a list of all available modules.
|
// Get a list of all available modules.
|
||||||
$modules = system_rebuild_module_data();
|
$modules = system_rebuild_module_data();
|
||||||
$uninstallable = array_filter($modules, function ($module) use ($modules) {
|
$uninstallable = array_filter($modules, function ($module) use ($modules) {
|
||||||
return empty($modules[$module->getName()]->info['required']) && drupal_get_installed_schema_version($module->getName()) > SCHEMA_UNINSTALLED;
|
return empty($modules[$module->getName()]->info['required']) && $module->status;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Include system.admin.inc so we can use the sort callbacks.
|
// Include system.admin.inc so we can use the sort callbacks.
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace Drupal\system\Tests\Module;
|
||||||
|
|
||||||
use Drupal\Core\Cache\Cache;
|
use Drupal\Core\Cache\Cache;
|
||||||
use Drupal\Component\Utility\SafeMarkup;
|
use Drupal\Component\Utility\SafeMarkup;
|
||||||
|
use Drupal\Core\Entity\EntityMalformedException;
|
||||||
use Drupal\simpletest\WebTestBase;
|
use Drupal\simpletest\WebTestBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,4 +118,31 @@ class UninstallTest extends WebTestBase {
|
||||||
$this->assertUrl('admin/modules/uninstall');
|
$this->assertUrl('admin/modules/uninstall');
|
||||||
$this->assertTitle(t('Uninstall') . ' | Drupal');
|
$this->assertTitle(t('Uninstall') . ' | Drupal');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that a module which fails to install can still be uninstalled.
|
||||||
|
*/
|
||||||
|
public function testFailedInstallStatus() {
|
||||||
|
$account = $this->drupalCreateUser(array('administer modules'));
|
||||||
|
$this->drupalLogin($account);
|
||||||
|
|
||||||
|
$message = 'Exception thrown when installing module_installer_config_test with an invalid configuration file.';
|
||||||
|
try {
|
||||||
|
$this->container->get('module_installer')->install(array('module_installer_config_test'));
|
||||||
|
$this->fail($message);
|
||||||
|
} catch (EntityMalformedException $e) {
|
||||||
|
$this->pass($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Even though the module failed to install properly, its configuration
|
||||||
|
// status is "enabled" and should still be available to uninstall.
|
||||||
|
$this->drupalGet('admin/modules/uninstall');
|
||||||
|
$this->assertText('Module installer config test');
|
||||||
|
$edit['uninstall[module_installer_config_test]'] = TRUE;
|
||||||
|
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
|
||||||
|
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
|
||||||
|
$this->assertText(t('The selected modules have been uninstalled.'));
|
||||||
|
$this->assertNoText('Module installer config test');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
# This entity is intentionally missing an 'id' key. During installation, an
|
||||||
|
# EntityMalformedException should be thrown about the missing key.
|
||||||
|
name: 'This entity does not have an ID'
|
|
@ -0,0 +1,10 @@
|
||||||
|
module_installer_config_test.type.*:
|
||||||
|
type: config_entity
|
||||||
|
label: 'Test entity type'
|
||||||
|
mapping:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: label
|
||||||
|
label: 'Name'
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
name: 'Module installer config test'
|
||||||
|
description: 'Support module for tests that require a failed module install.'
|
||||||
|
type: module
|
||||||
|
package: Testing
|
||||||
|
core: 8.x
|
||||||
|
version: VERSION
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains \Drupal\module_installer_config_test\Entity\TestConfigType.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\module_installer_config_test\Entity;
|
||||||
|
|
||||||
|
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a configuration-based entity type used for testing.
|
||||||
|
*
|
||||||
|
* @ConfigEntityType(
|
||||||
|
* id = "test_config_type",
|
||||||
|
* label = @Translation("Test entity type"),
|
||||||
|
* handlers = {
|
||||||
|
* "list_builder" = "Drupal\Core\Entity\EntityListBuilder"
|
||||||
|
* },
|
||||||
|
* admin_permission = "administer modules",
|
||||||
|
* config_prefix = "type",
|
||||||
|
* entity_keys = {
|
||||||
|
* "id" = "id",
|
||||||
|
* "label" = "name"
|
||||||
|
* }
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
class TestConfigType extends ConfigEntityBase {
|
||||||
|
}
|
Loading…
Reference in New Issue