Skip to content

Commit 1c55eae

Browse files
committed
Eliminate method in favor of closure
1 parent 2111d68 commit 1c55eae

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tests/phpunit/tests/pluggable/wpMail.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -719,13 +719,6 @@ public function test_wp_mail_plain_and_html() {
719719
);
720720
}
721721

722-
/*
723-
* 'phpmailer_init' action for test_wp_mail_plain_and_html_workaround().
724-
*/
725-
public function wp_mail_set_alt_body( $mailer ) {
726-
$mailer->AltBody = strip_tags( $mailer->Body );
727-
}
728-
729722
/**
730723
* Check workarounds using phpmailer_init still work around.
731724
*
@@ -736,9 +729,12 @@ public function test_wp_mail_plain_and_html_workaround() {
736729
$subject = 'Test email with plain text derived from html version';
737730
$message = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><p>Hello World! γειά σου Κόσμε</p></body></html>';
738731

739-
add_action( 'phpmailer_init', array( $this, 'wp_mail_set_alt_body' ) );
732+
$set_alt_body = static function ( WP_PHPMailer $mailer ) {
733+
$mailer->AltBody = strip_tags( $mailer->Body );
734+
};
735+
add_action( 'phpmailer_init', $set_alt_body );
740736
wp_mail( $to, $subject, $message );
741-
remove_action( 'phpmailer_init', array( $this, 'wp_mail_set_alt_body' ) );
737+
remove_action( 'phpmailer_init', $set_alt_body );
742738

743739
$mailer = tests_retrieve_phpmailer_instance();
744740

0 commit comments

Comments
 (0)