Skip to content

Commit

Permalink
Mock the PHP mailer earlier and prevent sending mail on wp_install (#534
Browse files Browse the repository at this point in the history
)

* Mock the PHP mailer earlier and prevent sending mail on wp_install

* CHANGELOG
  • Loading branch information
srtfisher authored Apr 19, 2024
1 parent 4c8c2dd commit f46f833
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.0.7 - 2024-04-19

### Fixed

- Prevent sending mail during the install `wp_install()` call in unit tests by
mocking the `$phpmailer` global earlier.

## v1.0.6 - 2024-04-19

### Fixed
Expand Down
1 change: 0 additions & 1 deletion src/mantle/testing/concerns/trait-interacts-with-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Mantle\Testing\Concerns;

use Mantle\Support\Collection;
use Mantle\Testing\Doubles\MockPHPMailer;
use Mantle\Testing\Mail\Mail_Message;
use Mantle\Testing\Mail\Mock_Mailer;

Expand Down
5 changes: 3 additions & 2 deletions src/mantle/testing/wordpress-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @package Mantle
*/

use Mantle\Testing\Doubles\MockPHPMailer;
use Mantle\Testing\Utils;
use Mantle\Testing\WP_Die;

Expand All @@ -29,7 +28,6 @@
$wp_rewrite,
$shortcode_tags,
$wp,
$phpmailer,
$table_prefix,
$wp_theme_directories,
$PHP_SELF;
Expand Down Expand Up @@ -122,6 +120,9 @@
$multisite = $multisite || ( defined( 'WP_TESTS_MULTISITE' ) && WP_TESTS_MULTISITE );
$multisite = $multisite || ( defined( 'MULTISITE' ) && MULTISITE );

// Replace the global phpmailer instance with a mock instance.
reset_phpmailer_instance();

// Include a WP_UnitTestCase class to allow for easier transition to the testing
// framework.
if ( ! Utils::env( 'DISABLE_WP_UNIT_TEST_CASE_SHIM', false ) ) {
Expand Down

0 comments on commit f46f833

Please sign in to comment.