Commit 92f3fe1a authored by catch's avatar catch
Browse files

Issue #2986464 by alexpott, xjm: ConfigImportAllTest should not make any...

Issue #2986464 by alexpott, xjm: ConfigImportAllTest should not make any assumptions about what modules/entity types exist in core
parent 98430f12
......@@ -3,12 +3,9 @@
namespace Drupal\Tests\config\Functional;
use Drupal\Core\Config\StorageComparer;
use Drupal\filter\Entity\FilterFormat;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Tests\SchemaCheckTestTrait;
use Drupal\Tests\system\Functional\Module\ModuleTestBase;
use Drupal\workspace\Entity\Workspace;
* Tests the largest configuration import possible with all available modules.
......@@ -73,31 +70,23 @@ public function testInstallUninstall() {
// Delete every field on the site so all modules can be uninstalled. For
// example, if a comment field exists then module becomes required and can
// not be uninstalled.
// Delete all entities provided by modules that prevent uninstallation. For
// example, if any content entity exists its provider cannot be uninstalled.
// So deleting all taxonomy terms allows the Taxonomy to be uninstalled.
// Additionally, every field is deleted so modules can be uninstalled. For
// example, if a comment field exists then Comment cannot be uninstalled.
$entity_type_manager = \Drupal::entityTypeManager();
foreach ($entity_type_manager->getDefinitions() as $entity_type) {
if (($entity_type instanceof ContentEntityTypeInterface || in_array($entity_type->id(), ['field_storage_config', 'filter_format'], TRUE))
&& !in_array($entity_type->getProvider(), ['system', 'user'], TRUE)) {
$storage = $entity_type_manager->getStorage($entity_type->id());
$field_storages = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple();
// Purge the data.
// Purge the field data.
// Delete all terms.
$terms = Term::loadMultiple();
entity_delete_multiple('taxonomy_term', array_keys($terms));
// Delete all filter formats.
$filters = FilterFormat::loadMultiple();
entity_delete_multiple('filter_format', array_keys($filters));
// Delete any shortcuts so the shortcut module can be uninstalled.
$shortcuts = Shortcut::loadMultiple();
entity_delete_multiple('shortcut', array_keys($shortcuts));
// Delete any workspaces so the workspace module can be uninstalled.
$workspaces = Workspace::loadMultiple();
$all_modules = system_rebuild_module_data();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment