*/
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.
*
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();
}