$this->assertEquals('Test Contact - Housing Support', $recent[0]['title']);
}
- /**
- * Create and return case object of given Client ID.
- * @param $clientId
- * @param $loggedInUser
- * @return CRM_Case_BAO_Case
- */
- private function createCase($clientId, $loggedInUser = NULL) {
- if (empty($loggedInUser)) {
- // backwards compatibility - but it's more typical that the creator is a different person than the client
- $loggedInUser = $clientId;
- }
- $caseParams = [
- 'activity_subject' => 'Case Subject',
- 'client_id' => $clientId,
- 'case_type_id' => 1,
- 'status_id' => 1,
- 'case_type' => 'housing_support',
- 'subject' => 'Case Subject',
- 'start_date' => date("Y-m-d"),
- 'start_date_time' => date("YmdHis"),
- 'medium_id' => 2,
- 'activity_details' => '',
- ];
- $form = new CRM_Case_Form_Case();
- $caseObj = $form->testSubmit($caseParams, "OpenCase", $loggedInUser, "standalone");
- return $caseObj;
- }
-
/**
* Create case role relationship between given contacts for provided case ID.
*
}
}
- /**
- * Create and return case object of given Client ID.
- * @todo This is copy/paste from Case/BAO/CaseTest - should put into base class?
- * @param $clientId
- * @param $loggedInUser
- * @return CRM_Case_BAO_Case
- */
- private function createCase($clientId, $loggedInUser = NULL) {
- if (empty($loggedInUser)) {
- // backwards compatibility - but it's more typical that the creator is a different person than the client
- $loggedInUser = $clientId;
- }
- $caseParams = [
- 'activity_subject' => 'Case Subject',
- 'client_id' => $clientId,
- 'case_type_id' => 1,
- 'status_id' => 1,
- 'case_type' => 'housing_support',
- 'subject' => 'Case Subject',
- 'start_date' => date("Y-m-d"),
- 'start_date_time' => date("YmdHis"),
- 'medium_id' => 2,
- 'activity_details' => '',
- ];
- $form = new CRM_Case_Form_Case();
- $caseObj = $form->testSubmit($caseParams, "OpenCase", $loggedInUser, "standalone");
- return $caseObj;
- }
-
/**
* Tests when the default assignee relationship exists, but in the other direction only.
* Ana is a pupil, but has no pupils related to her.
'prefix_id' => NULL,
'suffix_id' => NULL,
]);
- $caseObj = $this->createCase($client_id, $this->_loggedInUser);
+ $caseObj = $this->createCase($client_id, $this->_loggedInUser, ['start_date' => '2019-11-14', 'start_date_time' => '20191114000000']);
$case_id = $caseObj->id;
// Add an additional meeting activity not in the timeline to the case.
'prefix_id' => NULL,
'suffix_id' => NULL,
]);
- $caseObj = $this->createCase($client_id, $this->_loggedInUser);
+ $caseObj = $this->createCase($client_id, $this->_loggedInUser, ['start_date' => '2019-11-14', 'start_date_time' => '20191114000000']);
$case_id = $caseObj->id;
// Now update the timeline so it has Meeting in it.
}
}
- /**
- * Create and return a new case object.
- * @param $clientId
- * @param $loggedInUser
- * @return CRM_Case_BAO_Case
- */
- private function createCase($clientId, $loggedInUser) {
- $caseParams = [
- 'activity_subject' => 'Case Subject',
- 'client_id' => $clientId,
- 'case_type_id' => $this->caseTypeId,
- 'status_id' => 1,
- 'case_type' => $this->caseType,
- 'subject' => 'Case Subject',
- 'start_date' => '2019-11-14',
- 'start_date_time' => '20191114000000',
- 'medium_id' => 2,
- 'activity_details' => '',
- ];
- $form = new CRM_Case_Form_Case();
- $caseObj = $form->testSubmit($caseParams, "OpenCase", $loggedInUser, "standalone");
- return $caseObj;
- }
-
/**
* We don't need so many activities as in the stock case type. Just makes
* dataprovider unnecessarily long. Just take the first two.
$this->assertEquals(0, $checkDeleted['count']);
}
+ /**
+ * Create and return a case object for the given Client ID.
+ *
+ * @param int $clientId
+ * @param int $loggedInUser
+ * Omit or pass NULL to use the same as clientId
+ * @param array $extra
+ * Optional specific parameters such as start_date
+ *
+ * @return CRM_Case_BAO_Case
+ */
+ public function createCase($clientId, $loggedInUser = NULL, $extra = NULL) {
+ if (empty($loggedInUser)) {
+ // backwards compatibility - but it's more typical that the creator is a different person than the client
+ $loggedInUser = $clientId;
+ }
+ $caseParams = [
+ 'activity_subject' => 'Case Subject',
+ 'client_id' => $clientId,
+ 'case_type_id' => 1,
+ 'status_id' => 1,
+ 'case_type' => 'housing_support',
+ 'subject' => 'Case Subject',
+ 'start_date' => ($extra['start_date'] ?? date("Y-m-d")),
+ 'start_date_time' => ($extra['start_date_time'] ?? date("YmdHis")),
+ 'medium_id' => 2,
+ 'activity_details' => '',
+ ];
+ $form = new CRM_Case_Form_Case();
+ $caseObj = $form->testSubmit($caseParams, "OpenCase", $loggedInUser, "standalone");
+ return $caseObj;
+ }
+
}