Created
January 4, 2020 04:04
-
-
Save csaborio001/9f706ec3e376eab26e792ae36a891db1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public function test_one_off_trigger_vol_police_report_five_days_prior_expiry_notify_area_coordinator() { | |
// Create the pending trigger. | |
$notifications = array( | |
'all_area_coordinators', | |
); | |
$trigger_id = $this->create_trigger_post( 'one_off', 'volunteer', '_police_report_expiry_date', 'ACTUALDATE', $notifications ); | |
// Create the area_coordinator for notification, associate user. | |
$expected_email = '[email protected]'; | |
$assigned_area_coordinator_user = $this->factory->user->create( | |
array( | |
'user_login' => 'assigned_area_coordinator_one', | |
'user_email' => $expected_email, | |
'role' => 'area_coordinator', | |
) | |
); | |
$assigned_area_coordinator_post_id = $this->create_entity_post( 'area_coordinator', 'under_review' ); | |
$result = update_field( 'participant_id', $assigned_area_coordinator_user, $assigned_area_coordinator_post_id ); | |
// Create the volunteer post that will have the police report expiry date. | |
$volunteer_post_id = $this->create_entity_post( 'volunteer' ); | |
// Set the police report expiry date to five days from now. | |
$time_now = (new \DateTime('now', new \DateTimeZone('Australia/Sydney')))->format('Ymd'); | |
$result = update_field( '_police_report_expiry_date', $time_now, $volunteer_post_id ); | |
// Run the trigger. | |
$tr = new Trigger_Run(); | |
$triggered_posts = $tr->execute_triggers( false ); | |
$emails = $this->get_trigger_entity_table_column( 'notification_targets', $trigger_id ); | |
$all_emails = array(); | |
$email_count = count( $emails ); | |
for ( $i = 0; $i < $email_count; $i++ ) { | |
$all_emails[] = $emails[ $i ]->notification_targets; | |
} | |
// Assert the results. | |
$expected = array( | |
$expected_email, | |
); | |
$this->assertEquals( $expected, $all_emails ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment