$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).
*/
$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'];
$this->assertTrue((bool) preg_match('/Includer Person/', $previewNames[0]), "Name 'Includer Person' should appear in '" . $previewNames[0] . '"');
}
- public function testMailerPreviewRecipientsDeduplicate() {
+ /**
+ * Test if Mailing recipients include duplicate OR on_hold emails
+ */
+ public function testMailerPreviewRecipientsDeduplicateAndOnholdEmails() {
// BEGIN SAMPLE DATA
$groupIDs['grp'] = $this->groupCreate(array('name' => 'Example group', 'title' => 'Example group'));
$contactIDs['include_me'] = $this->individualCreate(array(
'first_name' => 'IncluderDuplicate',
'last_name' => 'Person',
));
+
+ $contactIDs['include_me_onhold'] = $this->individualCreate(array(
+ 'email' => 'onholdinclude.me@example.org',
+ 'first_name' => 'Onhold',
+ 'last_name' => 'Person',
+ ));
+ $emailId = $this->callAPISuccessGetValue('Email', array(
+ 'return' => 'id',
+ 'contact_id' => $contactIDs['include_me_onhold'],
+ ));
+ $this->callAPISuccess('Email', 'create', array(
+ 'id' => $emailId,
+ 'on_hold' => TRUE,
+ ));
+
$this->callAPISuccess('GroupContact', 'create', array(
'group_id' => $groupIDs['grp'],
'contact_id' => $contactIDs['include_me'],
'group_id' => $groupIDs['grp'],
'contact_id' => $contactIDs['include_me_duplicate'],
));
+ $this->callAPISuccess('GroupContact', 'create', array(
+ 'group_id' => $groupIDs['grp'],
+ 'contact_id' => $contactIDs['include_me_onhold'],
+ ));
$params = $this->_params;
$params['groups']['include'] = array($groupIDs['grp']);
$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(
$create = $this->callAPISuccess('Mailing', 'create', $params);
+ //Recipient should not contain duplicate or on_hold emails.
$preview = $create['values'][$create['id']]['api.MailingRecipients.get'];
$this->assertEquals(1, $preview['count']);
$previewEmails = array_values(CRM_Utils_Array::collect('api.email.getvalue', $preview['values']));
'Opened' => 20,
'Unique Clicks' => 0,
'Unsubscribers' => 20,
+ 'delivered_rate' => '80%',
+ 'opened_rate' => '25%',
+ 'clickthrough_rate' => '0%',
);
$this->checkArrayEquals($expectedResult, $result['values'][$mail['id']]);
}