-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not send organiser reminders with "send X days after the camp ends…
…" trigger if WordCamp didn't happen (#970) * add wordcamp public status check for emails set to send with wcor_send_after. * fix test for wcor_send_after. * add tests for wcor_send_after when wordcamp does not have public status --------- Co-authored-by: ren <[email protected]>
- Loading branch information
1 parent
4bbcc10
commit f5adc25
Showing
2 changed files
with
73 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,13 +155,18 @@ public function test_triggered_message_sent() { | |
* | ||
* @covers WCOR_Mailer::send_timed_emails | ||
*/ | ||
public function test_timed_messages_sent( $send_when, $send_when_period, $send_when_days, $compare_date ) { | ||
public function test_timed_messages_sent( $send_when, $send_when_period, $send_when_days, $compare_date, $wordcamp_post_status ) { | ||
/** @var WCOR_Mailer $WCOR_Mailer */ | ||
global $WCOR_Mailer; | ||
|
||
update_post_meta( self::$timed_reminder_post_id, 'wcor_send_when', $send_when ); | ||
update_post_meta( self::$timed_reminder_post_id, $send_when_period, $send_when_days ); | ||
|
||
wp_update_post( array( | ||
'ID' => self::$wordcamp_dayton_post_id, | ||
'post_status' => $wordcamp_post_status, | ||
) ); | ||
|
||
if ( in_array( $send_when, array( 'wcor_send_before', 'wcor_send_after', 'wcor_send_after_and_no_report' ) ) ) { | ||
update_post_meta( self::$wordcamp_dayton_post_id, 'Start Date (YYYY-mm-dd)', $compare_date ); | ||
} elseif ( 'wcor_send_after_pending' === $send_when ) { | ||
|
@@ -174,14 +179,18 @@ public function test_timed_messages_sent( $send_when, $send_when_period, $send_w | |
|
||
do_action( 'wcor_send_timed_emails' ); | ||
|
||
$this->assert_mail_succeeded( | ||
'[email protected]', | ||
"It's time to submit WordCamp Dayton reimbursement requests", | ||
"Howdy Sally Smith, now's the perfect time to request reimbursement for any out of pocket expenses. You can do that at https://2019.dayton.wordcamp.org/wp-admin/edit.php?post_type=wcb_reimbursement.\n" | ||
); | ||
|
||
$this->assertIsArray( $wordcamp->wcor_sent_email_ids ); | ||
$this->assertContains( self::$timed_reminder_post_id, $wordcamp->wcor_sent_email_ids ); | ||
if ( 'wcor_send_after' === $send_when && 'wcpt-cancelled' === $wordcamp_post_status ) { | ||
$this->assertSame( '', $wordcamp->wcor_sent_email_ids ); | ||
} else { | ||
$this->assert_mail_succeeded( | ||
'[email protected]', | ||
"It's time to submit WordCamp Dayton reimbursement requests", | ||
"Howdy Sally Smith, now's the perfect time to request reimbursement for any out of pocket expenses. You can do that at https://2019.dayton.wordcamp.org/wp-admin/edit.php?post_type=wcb_reimbursement.\n" | ||
); | ||
|
||
$this->assertIsArray( $wordcamp->wcor_sent_email_ids ); | ||
$this->assertContains( self::$timed_reminder_post_id, $wordcamp->wcor_sent_email_ids ); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -197,6 +206,7 @@ public function data_timed_messages_sent() { | |
'wcor_send_days_before', | ||
3, | ||
strtotime( 'now + 3 days' ), | ||
'wcpt-scheduled', | ||
), | ||
|
||
// After the camp ends. | ||
|
@@ -205,6 +215,16 @@ public function data_timed_messages_sent() { | |
'wcor_send_days_after', | ||
3, | ||
strtotime( 'now - 3 days' ), | ||
'wcpt-scheduled', | ||
), | ||
|
||
// After the camp ends but it does not have public status. | ||
array( | ||
'wcor_send_after', | ||
'wcor_send_days_after', | ||
3, | ||
strtotime( 'now - 3 days' ), | ||
'wcpt-cancelled', | ||
), | ||
|
||
// After added to the pending schedule. | ||
|
@@ -213,6 +233,7 @@ public function data_timed_messages_sent() { | |
'wcor_send_days_after_pending', | ||
3, | ||
strtotime( 'now - 3 days' ), | ||
'wcpt-scheduled', | ||
), | ||
|
||
// After the camp ends and no transparency report is received. | ||
|
@@ -221,6 +242,7 @@ public function data_timed_messages_sent() { | |
'wcor_send_days_after_and_no_report', | ||
3, | ||
strtotime( 'now - 3 days' ), | ||
'wcpt-scheduled', | ||
), | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters