Skip to content

Commit

Permalink
Add api testing / custom data support for MailingJob.
Browse files Browse the repository at this point in the history
There is no specific requirement for MailingJob to have custom data - but
this is generally part of standardising all entities to support custom
data (ie. workign through the list in
api_v3_SyntaxConformanceTest:toBeSkipped_custom_data_creatable
 to remove the remaining rows.
  • Loading branch information
eileenmcnaughton committed May 29, 2018
1 parent 3832b5e commit 593cec9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
16 changes: 6 additions & 10 deletions CRM/Mailing/BAO/MailingJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,16 @@ public function __construct() {
* @throws \CRM_Core_Exception
*/
static public function create($params) {
if (!$params['id'] && empty($params['mailing_id'])) {
throw new CRM_Core_Exception("Failed to create job: Unknown mailing ID");
}
$job = new CRM_Mailing_BAO_MailingJob();
$job->mailing_id = $params['mailing_id'];
$job->status = $params['status'];
$job->scheduled_date = $params['scheduled_date'];
$job->is_test = $params['is_test'];
$job->copyValues($params, TRUE);
$job->save();
if ($params['mailing_id']) {
if (!empty($params['mailing_id'])) {
CRM_Mailing_BAO_Mailing::getRecipients($params['mailing_id']);
return $job;
}
else {
throw new CRM_Core_Exception("Failed to create job: Unknown mailing ID");
}
return $job;
}

/**
Expand All @@ -89,7 +86,6 @@ static public function create($params) {
public static function runJobs($testParams = NULL, $mode = NULL) {
$job = new CRM_Mailing_BAO_MailingJob();

$config = CRM_Core_Config::singleton();
$jobTable = CRM_Mailing_DAO_MailingJob::getTableName();
$mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
$mailerBatchLimit = Civi::settings()->get('mailerBatchLimit');
Expand Down
2 changes: 1 addition & 1 deletion api/v3/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function civicrm_api3_mailing_delete($params) {
* @return array
*/
function civicrm_api3_mailing_get($params) {
$result = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
$result = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'MailingJob');
return _civicrm_api3_mailing_get_formatResult($result);
}

Expand Down
2 changes: 1 addition & 1 deletion api/v3/MailingJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @throws \API_Exception
*/
function civicrm_api3_mailing_job_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MailingJob');
}

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/api/v3/SyntaxConformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ public static function toBeSkipped_custom_data_creatable($sequential = FALSE) {
'MailingEventResubscribe',
'MailingEventSubscribe',
'MailingEventUnsubscribe',
'MailingJob',
'MembershipPayment',
'SavedSearch',
'UFJoin',
Expand Down Expand Up @@ -488,7 +487,6 @@ public static function toBeSkipped_updatesingle($sequential = FALSE) {
// pseudo-entity; testUpdateSingleValueAlter doesn't introspect properly on it. Multiple magic fields
'Mailing',
'MailingGroup',
'MailingJob',
'Address',
'MailingEventUnsubscribe',
'MailingEventSubscribe',
Expand Down

0 comments on commit 593cec9

Please sign in to comment.