protected $hookCache = NULL;
/**
- * Symbolic names of case-types.
+ * Override case types, only used by unit tests
*
* @var array|null
*/
- protected $allCaseTypes = NULL;
+ protected $unitTestCaseTypes = NULL;
/**
* @param bool $fresh
public function flush() {
$this->xml = [];
$this->hookCache = NULL;
- $this->allCaseTypes = NULL;
+ $this->unitTestCaseTypes = NULL;
CRM_Core_DAO::$_dbColumnValueCache = [];
}
/**
* Class constructor.
*
- * @param array $allCaseTypes
+ * @param array $unitTestCaseTypes
* @param array $xml
*/
- public function __construct($allCaseTypes = NULL, $xml = []) {
- $this->allCaseTypes = $allCaseTypes;
+ public function __construct($unitTestCaseTypes = NULL, $xml = []) {
+ $this->unitTestCaseTypes = $unitTestCaseTypes;
$this->xml = $xml;
}
}
/**
- * @return array<string> symbolic names of case-types
+ * @return string[]
+ * symbolic names of case-types
*/
public function getAllCaseTypes() {
- if ($this->allCaseTypes === NULL) {
- $this->allCaseTypes = CRM_Case_PseudoConstant::caseType("name");
- }
- return $this->allCaseTypes;
+ return $this->unitTestCaseTypes ?? CRM_Case_PseudoConstant::caseType("name");
}
/**
$this->assertEquals(TRUE, $items[0]['is_active']);
$this->assertEquals(1, count($items));
- // This is normally handled by `CRM_Case_BAO_CaseType` calling `CRM_Core_ManagedEntities::scheduleReconciliation`
- // But due to timing issues with the E2E tests the scheduled reconciliation hasn't happened yet.
- \Civi\Api4\Managed::reconcile(FALSE)->addModule('civicrm')->execute();
-
$actTypes = $cv->api4('OptionValue', 'get', [
'where' => [['option_group_id:name', '=', 'activity_type'], ['name', '=', 'Nibble']],
]);
$items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'BunnyDance']]]);
$this->assertEquals(0, count($items));
- // This is normally handled by `CRM_Case_BAO_CaseType` calling `CRM_Core_ManagedEntities::scheduleReconciliation`
- // But static caching seems to interfere.
- \Civi\Api4\Managed::reconcile(FALSE)->execute();
- \CRM_Core_PseudoConstant::flush();
- \Civi\Api4\Managed::reconcile(FALSE)->addModule('civicrm')->execute();
-
$actTypes = $cv->api4('OptionValue', 'get', [
'where' => [['option_group_id:name', '=', 'activity_type'], ['name', '=', 'Nibble']],
]);