$this->getAndCheck($this->_params, $result['id'], 'mailing');
}
+ /**
+ * Tes that the parameter _skip_evil_bao_auto_schedule_ is respected & prevents jobs being created.
+ */
+ public function testSkipAutoSchedule() {
+ $this->callAPISuccess('Mailing', 'create', array_merge($this->_params, [
+ '_skip_evil_bao_auto_schedule_' => TRUE,
+ 'scheduled_date' => 'now'
+ ]));
+ $this->callAPISuccessGetCount('Mailing', [], 1);
+ $this->callAPISuccessGetCount('MailingJob', [], 0);
+ }
+
+ /**
+ * Create a completed mailing (e.g when importing from a provider).
+ */
+ public function testMailerCreateCompleted() {
+ $this->_params['body_html'] = 'I am completed so it does not matter if there is an opt out link since I have already been sent by another system';
+ $this->_params['is_completed'] = 1;
+ $result = $this->callAPIAndDocument('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__);
+ $jobs = $this->callAPISuccess('mailing_job', 'get', array('mailing_id' => $result['id']));
+ $this->assertEquals(1, $jobs['count']);
+ $this->assertEquals('Complete', $jobs['values'][$jobs['id']]['status']);
+ unset($this->_params['created_id']); // return isn't working on this in getAndCheck so lets not check it for now
+ $this->getAndCheck($this->_params, $result['id'], 'mailing');
+ }
+
/**
* Per CRM-20316 the mailing should still create without created_id (not mandatory).
*/
$params['mailings']['include'] = array();
$params['mailings']['exclude'] = array();
$params['options']['force_rollback'] = 1;
- $params['api.mailing_job.create'] = 1;
$params['api.MailingRecipients.get'] = array(
'mailing_id' => '$value.id',
'api.contact.getvalue' => array(
$maxIDs = array(
'mailing' => CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing'),
- 'job' => CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_job'),
'group' => CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_group'),
);
$create = $this->callAPIAndDocument('Mailing', 'create', $params, __FUNCTION__, __FILE__);
$this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); // 'Preview should not create any mailing records'
- $this->assertDBQuery($maxIDs['job'], 'SELECT MAX(id) FROM civicrm_mailing_job'); // 'Preview should not create any mailing_job record'
$this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); // 'Preview should not create any mailing_group records'
$preview = $create['values'][$create['id']]['api.MailingRecipients.get'];
$params['mailings']['include'] = array();
$params['options']['force_rollback'] = 1;
$params['dedupe_email'] = 1;
- $params['api.mailing_job.create'] = 1;
$params['api.MailingRecipients.get'] = array(
'mailing_id' => '$value.id',
'api.contact.getvalue' => array(