WordPress.org

Make WordPress Core

Ticket #28618: 28618.diff

File 28618.diff, 1.8 KB (added by leewillis77, 4 years ago)
  • src/wp-includes/pluggable.php

     
    265265                require_once ABSPATH . WPINC . '/class-phpmailer.php';
    266266                require_once ABSPATH . WPINC . '/class-smtp.php';
    267267                $phpmailer = new PHPMailer( true );
     268                /**
     269                 * Filters the PHPMailer object.
     270                 *
     271                 * Allows plugins to override the PHPMailer class with one of their own if required.
     272                 *
     273                 * @since 4.0
     274                 *
     275                 * @param object $phpmailer A PHPMailer (or compatible) class.
     276                 */
     277                $phpmailer = apply_filters( 'wp_phpmailer', $phpmailer );
    268278        }
    269279
    270280        // Headers
  • tests/phpunit/includes/bootstrap.php

     
    4545        $multisite = false;
    4646}
    4747
    48 // Override the PHPMailer
     48// Override the PHPMailer up front
    4949require_once( dirname( __FILE__ ) . '/mock-mailer.php' );
    5050$phpmailer = new MockPHPMailer();
    5151
     
    6767
    6868require_once dirname( __FILE__ ) . '/functions.php';
    6969
     70// Ensure that PHPMailer is alwways a MockPHPMailer
     71tests_add_filter( 'wp_phpmailer', '_wp_phpmailer' );
     72
    7073$GLOBALS['_wp_die_disabled'] = false;
    7174// Allow tests to override wp_die
    7275tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' );
  • tests/phpunit/includes/functions.php

     
    102102                        echo "\t $k : $v\n";
    103103                }
    104104        }
    105 }
    106  No newline at end of file
     105}
     106
     107function _wp_phpmailer( $phpmailer ) {
     108        return new MockPHPMailer();
     109}