Skip to content
Snippets Groups Projects
Commit c0db4b22 authored by totten's avatar totten Committed by Eileen McNaughton
Browse files

ContributionTest - Auto-disable all newly activated extensions

parent 4432ceb9
Branches
Tags
No related merge requests found
......@@ -32,6 +32,26 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase {
*/
protected $entity = 'Contribution';
/**
* These extensions are inactive at the start. They may be activated during the test. They should be deactivated at the end.
*
* For the moment, the test is simply hard-coded to cleanup in a specific order. It's tempting to auto-detect and auto-uninstall these.
* However, the shape of their dependencies makes it tricky to auto-uninstall (e.g. some exts have managed-entities that rely on other
* exts -- you need to fully disable+uninstall the downstream managed-entity-ext before disabling or uninstalling the upstream
* entity-provider-ext).
*
* You may need to edit `$toggleExts` whenever the dependency-graph changes.
*
* @var string[]
*/
protected $toggleExts = ['civiimport', 'org.civicrm.search_kit', 'org.civicrm.afform', 'authx'];
protected function setUp(): void {
parent::setUp();
$origExtensions = array_column(CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(), 'fullName');
$this->assertEquals([], array_intersect($origExtensions, $this->toggleExts), 'These extensions may be enabled and disabled during the test. The start-state and end-state should be the same. It appears that we have an unexpected start-state. Perhaps another test left us with a weird start-state?');
}
/**
* Cleanup function.
*
......@@ -44,7 +64,10 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase {
DedupeRule::delete()
->addWhere('rule_table', '!=', 'civicrm_email')
->addWhere('dedupe_rule_group_id.name', '=', 'IndividualUnsupervised')->execute();
$this->callAPISuccess('Extension', 'disable', ['key' => 'civiimport']);
foreach ($this->toggleExts as $ext) {
CRM_Extension_System::singleton()->getManager()->disable([$ext]);
CRM_Extension_System::singleton()->getManager()->uninstall([$ext]);
}
parent::tearDown();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment