Make WordPress Core

source: trunk/tests/phpunit/includes/mock-mailer.php @ 35242

Last change on this file since 35242 was 33124, checked in by ocean90, 10 years ago

Update PHPMailer to 5.2.10 from 5.2.7.

Includes two modifications for WordPress:

  • Removes support for NTLM in class-smtp.php since the required client (extras/ntlm_sasl_client.php) is not distributed as part of WordPress.
  • Requires class-smtp.php for backwards compatibility with direct (non-wp_mail()) uses of PHPMailer, as the autoloader isn't used. See [27385].

This also includes a change to our MockMailer for unit tests. It now overrides postSend() instead of send(), and preSend()`.
preSend() resets $this->Encoding because PHPMailer doesn't clean up after itself / presets all variables. This becomes an issue when PHPMailer::createBody() sets $this->Encoding = 'quoted-printable' (away from it's default of 8bit) when it encounters a line longer than 998 characters. Tests_Comment::test_comment_field_lengths is such a case.

props MattyRob, dd32.
fixes #28909.

File size: 506 bytes
Line 
1<?php
2require_once( ABSPATH . '/wp-includes/class-phpmailer.php' );
3
4class MockPHPMailer extends PHPMailer {
5        var $mock_sent = array();
6
7        function preSend() {
8                $this->Encoding = '8bit';
9                return parent::preSend();
10        }
11
12        /**
13         * Override postSend() so mail isn't actually sent.
14         */
15        function postSend() {
16                $this->mock_sent[] = array(
17                        'to'     => $this->to,
18                        'cc'     => $this->cc,
19                        'bcc'    => $this->bcc,
20                        'header' => $this->MIMEHeader,
21                        'body'   => $this->MIMEBody,
22                );
23
24                return true;
25        }
26}
Note: See TracBrowser for help on using the repository browser.