Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] minimal test for Mailing.update_email_resetdate #15832

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ public static function &singleValueQuery(
* @param bool $abort
*
* @return string
* @throws Exception
* @throws CRM_Core_Exception
*/
public static function composeQuery($query, $params = [], $abort = TRUE) {
$tr = [];
Expand Down
1 change: 0 additions & 1 deletion CRM/Mailing/Event/BAO/Delivered.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ public static function bulkCreate($eventQueueIDs, $time = NULL) {
* Consider mailings that were completed not more than $maxDays ago.
*/
public static function updateEmailResetDate($minDays = 3, $maxDays = 7) {
$dao = new CRM_Core_DAO();

$temporaryTable = CRM_Utils_SQL_TempTable::build()
->setCategory('mailingemail')
Expand Down
4 changes: 2 additions & 2 deletions Civi/Test/DbTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ public function assertDBCompareValues($daoName, $searchParams, $expectedValues)
* @param array $params
* @param string $message
*
* @throws \Exception
* @throws \CRM_Core_Exception
*/
public function assertDBQuery($expected, $query, $params = array(), $message = '') {
public function assertDBQuery($expected, $query, $params = [], $message = '') {
if ($message) {
$message .= ': ';
}
Expand Down
33 changes: 31 additions & 2 deletions tests/phpunit/api/v3/MailingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public function testSkipAutoSchedule() {

/**
* Create a completed mailing (e.g when importing from a provider).
*
* @throws \CRM_Core_Exception
*/
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';
Expand Down Expand Up @@ -146,6 +148,8 @@ public function testHeaderFooterOptions() {
* The `template_options` field should be treated a JSON object.
*
* This test will create, read, and update the field.
*
* @throws \CRM_Core_Exception
*/
public function testMailerCreateTemplateOptions() {
// 1. Create mailing with template_options.
Expand Down Expand Up @@ -183,6 +187,8 @@ public function testMailerCreateTemplateOptions() {
/**
* The Mailing.create API supports magic properties "groups[include,enclude]" and "mailings[include,exclude]".
* Make sure these work
*
* @throws \CRM_Core_Exception
*/
public function testMagicGroups_create_update() {
// BEGIN SAMPLE DATA
Expand Down Expand Up @@ -369,6 +375,8 @@ public function testMailerPreviewRecipients() {

/**
* Test if Mailing recipients include duplicate OR on_hold emails
*
* @throws \CRM_Core_Exception
*/
public function testMailerPreviewRecipientsDeduplicateAndOnholdEmails() {
// BEGIN SAMPLE DATA
Expand Down Expand Up @@ -639,14 +647,16 @@ public function submitProvider() {
* @param array $submitParams
* @param null|string $expectedFailure
* @param int $expectedJobCount
*
* @dataProvider submitProvider
* @throws \CRM_Core_Exception
*/
public function testMailerSubmit($useLogin, $createParams, $submitParams, $expectedFailure, $expectedJobCount) {
if ($useLogin) {
$this->createLoggedInUser();
}

if (isset($createParams['footer_id']) && $createParams['footer_id'] == '%FOOTER%') {
if (isset($createParams['footer_id']) && $createParams['footer_id'] === '%FOOTER%') {
$createParams['footer_id'] = $this->footer['id'];
}

Expand All @@ -671,6 +681,9 @@ public function testMailerSubmit($useLogin, $createParams, $submitParams, $expec
/**
* Test unsubscribe list contains correct groups
* when include = 'previous mailing'
*
* @throws \CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
*/
public function testUnsubscribeGroupList() {
// Create set of groups and add a contact to both of them.
Expand Down Expand Up @@ -709,7 +722,7 @@ public function testUnsubscribeGroupList() {
'entity_id' => $mail['id'],
'group_type' => 'Include',
];
$mailingGroup = $this->callAPISuccess('MailingGroup', 'create', $mgParams);
$this->callAPISuccess('MailingGroup', 'create', $mgParams);
//CRM-20431 - Delete group id that matches first mailing id.
$this->callAPISuccess('Group', 'delete', ['id' => $this->_groupID]);
$jobId = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingJob', $mail2['id'], 'id', 'mailing_id');
Expand Down Expand Up @@ -799,6 +812,11 @@ public function testMailGetTokens() {
$this->assertArrayHasKey('id', $result['values'][0]['children'][0]);
}

/**
* Test clone function.
*
* @throws \CRM_Core_Exception
*/
public function testClone() {
// BEGIN SAMPLE DATA
$groupIDs['inc'] = $this->groupCreate(['name' => 'Example include group', 'title' => 'Example include group']);
Expand Down Expand Up @@ -950,6 +968,8 @@ public function createDraftMailing($params = []) {
/**
* Test to make sure that if the event queue hashes have been archived,
* we can still have working click-trough URLs working (CRM-17959).
*
* @throws \CRM_Core_Exception
*/
public function testUrlWithMissingTrackingHash() {
$mail = $this->callAPISuccess('mailing', 'create', $this->_params + ['scheduled_date' => 'now'], __FUNCTION__, __FILE__);
Expand Down Expand Up @@ -1028,4 +1048,13 @@ public function testModifiedDateMismatchOnMailingUpdate() {
}
}

/**
* Test that api Mailing.update_email_resetdate does not throw a core error.
*
* @throws \CRM_Core_Exception
*/
public function testUpdateEmailResetdate() {
$this->callAPISuccess('Mailing', 'update_email_resetdate', []);
}

}