if (!CRM_Utils_Array::value($caseType, $this->xml)) {
// first check custom templates directory
$fileName = NULL;
- $config = CRM_Core_Config::singleton();
- if (isset($config->customTemplateDir) &&
- $config->customTemplateDir
- ) {
- // check if the file exists in the custom templates directory
- $fileName = implode(DIRECTORY_SEPARATOR,
- array(
- $config->customTemplateDir,
- 'CRM',
- 'Case',
- 'xml',
- 'configuration',
- "$caseType.xml",
- )
- );
+
+ if (!$fileName || !file_exists($fileName)) {
+ $caseTypesViaHook = $this->getCaseTypesViaHook();
+ if (isset($caseTypesViaHook[$caseType], $caseTypesViaHook[$caseType]['file'])) {
+ $fileName = $caseTypesViaHook[$caseType]['file'];
+ }
}
- if (!$fileName ||
- !file_exists($fileName)
- ) {
- // check if file exists locally
- $fileName = implode(DIRECTORY_SEPARATOR,
- array(
- dirname(__FILE__),
- 'xml',
- 'configuration',
- "$caseType.xml",
- )
- );
+ if (!$fileName || !file_exists($fileName)) {
+ $config = CRM_Core_Config::singleton();
+ if (isset($config->customTemplateDir) && $config->customTemplateDir) {
+ // check if the file exists in the custom templates directory
+ $fileName = implode(DIRECTORY_SEPARATOR,
+ array(
+ $config->customTemplateDir,
+ 'CRM',
+ 'Case',
+ 'xml',
+ 'configuration',
+ "$caseType.xml",
+ )
+ );
+ }
+ }
+ if (!$fileName || !file_exists($fileName)) {
if (!file_exists($fileName)) {
// check if file exists locally
$fileName = implode(DIRECTORY_SEPARATOR,
array(
dirname(__FILE__),
'xml',
- 'configuration.sample',
+ 'configuration',
"$caseType.xml",
)
);
}
if (!file_exists($fileName)) {
- $caseTypesViaHook = $this->getCaseTypesViaHook();
- if (isset($caseTypesViaHook[$caseType], $caseTypesViaHook[$caseType]['file'])) {
- $fileName = $caseTypesViaHook[$caseType]['file'];
- }
+ // check if file exists locally
+ $fileName = implode(DIRECTORY_SEPARATOR,
+ array(
+ dirname(__FILE__),
+ 'xml',
+ 'configuration.sample',
+ "$caseType.xml",
+ )
+ );
}
if (!file_exists($fileName)) {
}
/**
- * @return array<int,string> symbolic names of case-types
+ * @return array<string> symbolic names of case-types
*/
public function getAllCaseTypes() {
if ($this->allCaseTypes === NULL) {
*/
class CiviCaseTestCase extends CiviUnitTestCase {
+ /**
+ * @var string symbolic-name
+ */
+ protected $caseType;
+
protected $caseTypeId;
+
protected $caseStatusGroup;
+
protected $optionValues;
+
protected $_loggedInUser;
public function setUp() {
parent::setUp();
+
+ /** @var $hooks \CRM_Utils_Hook_UnitTests */
+ $hooks = \CRM_Utils_Hook::singleton();
+ $hooks->setHook('civicrm_caseTypes', array($this, 'hook_caseTypes'));
+ \CRM_Case_XMLRepository::singleton(TRUE);
+
// CRM-9404 - set-up is a bit cumbersome but had to put something in place to set up activity types & case types
//. Using XML was causing breakage as id numbers were changing over time
// & was really hard to troubleshoot as involved truncating option_value table to mitigate this & not leaving DB in a
// store for cleanup
$this->optionValues[] = $activityTypes['id'];
}
+
+ // TODO Our data seems inconsistent on whether name is "HousingSupport" or "housing_support"
+ $this->caseType = 'HousingSupport';
$this->caseTypeId = 1;
$this->tablesToTruncate = array(
'civicrm_activity',
function tearDown() {
$this->quickCleanup($this->tablesToTruncate, TRUE);
$this->customDirectories(array('template_path' => FALSE));
+ CRM_Case_XMLRepository::singleton(TRUE);
+ }
+
+ /**
+ * Subclasses may override this if they want to be explicit about the case-type definition.
+ *
+ * @param $caseTypes
+ * @see CRM_Utils_Hook::caseTypes
+ */
+ function hook_caseTypes(&$caseTypes) {
}
}
\ No newline at end of file