Problem/Motivation

Removing the Workspaces module for the 8.6.0 alpha broke HEAD, because of this workaround code in ConfigImportAllTest:

    // 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();
    \Drupal::entityTypeManager()->getStorage('workspace')->delete($workspaces);

There is also this a few lines later:

    $this->assertTrue(isset($modules_to_uninstall['comment']), 'The comment module will be disabled');
    $this->assertTrue(isset($modules_to_uninstall['file']), 'The File module will be disabled');
    $this->assertTrue(isset($modules_to_uninstall['editor']), 'The Editor module will be disabled');

Ideally we would not hardcode the existence of any particular optional module in the config import test. In particular, there should not be references to experimental modules outside that module's directory.

Proposed resolution

TBD

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm created an issue. See original summary.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

The only real option here is would be to not include experimental modules in the modules that are installed by the test. Atm it installs all core provided modules. If those modules do things in their hook_install() that make them uninstallable then the test will fail. However if we don't install experimental modules in this test we miss important test coverage of them being installed via ConfigImport. I guess in an ideal world we could invert this and make such modules provide some code that allows them to be uninstalled.

Or another way would be to remove all the content entities supplied by modules that are going to be uninstalled... going to write a patch to do that.

alexpott’s picture

Status: Active » Needs review
FileSize
2.98 KB

Here's a way that the necessary content and config entity deletes are a bit more generalised and if we add to the list of config entity deletes in the future wouldn't break in the same way.

alexpott’s picture

Standard is never going to provide an entity type. (me thinks never say never but really hopefully in this case).

tstoeckler’s picture

So one way to fix this that I've thought about before is to not have a single test install and uninstall all modules but rather have something like ModuleTestBase that we extend from every single module that provides baseline coverage such as installing and uninstalling the module. I think the Rest test coverage has set a great example for this. Apart from the concrete benefit of fixing this issue, this would bring proper encapsulation and furthermore would allow contrib modules to benefit from this test coverage as well. We could then add/move additional tests to this base class to improve and define what we consider the "base line" functionality of a module, e.g. we could also move the testing of a hook_help() implementation there.

catch’s picture

Status: Needs review » Reviewed & tested by the community

So one way to fix this that I've thought about before is to not have a single test install and uninstall all modules but rather have something like ModuleTestBase that we extend from every single module that provides baseline coverage such as installing and uninstalling the module.

While this would be cleaner, the 'do everything at once approach' in this test has caught several bugs because it's such a horrible blunt instrument, that we'd never have thought to add explicit coverage for in the first place.

I think #5 is absolutely fine to fix the HEAD breakage, we can open a follow-up for other approaches if we want to.

phenaproxima’s picture

Read the patch, and it makes perfect sense to me. +1 RTBC.

amateescu’s picture

Uninstalling a module which provides content entities is now possible to do through the UI, thanks to the dedicated form for deleting all the entities of a certain type: admin/modules/uninstall/entity/<entity_type_id>

I think a better way to test that module are actually uninstallable through the UI, like this mega-test tries to prove, is to delete the existing content entities by using that form for each content entity type that has data instead of deleting them via API calls.

amateescu’s picture

Oops, @alexpott pointed out that purpose of this test is not to test module uninstalling via the UI, so ignore #9 :)

alexpott’s picture

@amateescu I'm not sure that this test is testing that modules are uninstallable via the UI per se. It's really testing that is a module is uninstallable it can be uninstalled via configuration import (which happens to occur via the UI).

  • catch committed 92f3fe1 on 8.7.x
    Issue #2986464 by alexpott, xjm: ConfigImportAllTest should not make any...

  • catch committed c9b9cc7 on 8.6.x
    Issue #2986464 by alexpott, xjm: ConfigImportAllTest should not make any...
catch’s picture

Version: 8.7.x-dev » 8.6.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 92f3fe1 and pushed to 8.7.x, cherry-picked to 8.6.x. Thanks!

Had to fix a cherry-pick conflict on 8.6.x due to the hotfix, so we should allow tests to clear before doing anything further.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.