*/
protected $origExtensionSystem;
+ /**
+ * Array of IDs created during test setup routine.
+ *
+ * The cleanUpSetUpIds method can be used to clear these at the end of the test.
+ *
+ * @var array
+ */
+ public $setupIDs = array();
+
/**
* Constructor.
*
public function membershipTypeCreate($params = array()) {
CRM_Member_PseudoConstant::flush('membershipType');
CRM_Core_Config::clearDBCache();
- $memberOfOrganization = $this->organizationCreate();
+ $this->setupIDs['contact'] = $memberOfOrganization = $this->organizationCreate();
$params = array_merge(array(
'name' => 'General',
'duration_unit' => 'year',
$this->callAPISuccessGetCount('FinancialItem', array('description' => 'Sales Tax', 'amount' => 0), 0);
}
+ /**
+ * Cleanup function for contents of $this->ids.
+ *
+ * This is a best effort cleanup to use in tear downs etc.
+ *
+ * It will not fail if the data has already been removed (some tests may do
+ * their own cleanup).
+ */
+ protected function cleanUpSetUpIDs() {
+ foreach ($this->setupIDs as $entity => $id) {
+ try {
+ civicrm_api3($entity, 'delete', array('id' => $id, 'skip_undelete' => 1));
+ }
+ catch (CiviCRM_API3_Exception $e) {
+ // This is a best-effort cleanup function, ignore.
+ }
+ }
+ }
+
}