From e91f9e91a7dce8828458538e43908fd205ad6d4d Mon Sep 17 00:00:00 2001 From: Mikko Saari Date: Wed, 12 Aug 2020 09:11:36 +0300 Subject: [PATCH 1/5] Updates PHPMailer for WP 5.5 WP 5.5 deprecates the old PHPMailer location and moves the class to a different file and separate namespace. This fix uses the correct PHPMailer class depending on the WP version. --- src/phpunit/includes/install.php | 1 + src/phpunit/includes/mock-mailer.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/phpunit/includes/install.php b/src/phpunit/includes/install.php index 45c0d60..912d8a4 100644 --- a/src/phpunit/includes/install.php +++ b/src/phpunit/includes/install.php @@ -24,6 +24,7 @@ tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter_exit' ); +define( 'WP_REPAIRING', true ); require_once ABSPATH . '/wp-settings.php'; require_once ABSPATH . '/wp-admin/includes/upgrade.php'; diff --git a/src/phpunit/includes/mock-mailer.php b/src/phpunit/includes/mock-mailer.php index ece2aa3..319b6ab 100644 --- a/src/phpunit/includes/mock-mailer.php +++ b/src/phpunit/includes/mock-mailer.php @@ -1,7 +1,16 @@ =' ) ) { + require_once ABSPATH . '/wp-includes/PHPMailer/PHPMailer.php'; + class MailerClass extends PHPMailer\PHPMailer\PHPMailer {} +} else { + require_once ABSPATH . '/wp-includes/class-phpmailer.php'; + class MailerClass extends PHPMailer {} +} + +class MockPHPMailer extends MailerClass { -class MockPHPMailer extends PHPMailer { var $mock_sent = array(); function preSend() { From a4f126c8845a998f78a39f123b0eb3e052befc29 Mon Sep 17 00:00:00 2001 From: Mikko Saari Date: Wed, 12 Aug 2020 09:14:52 +0300 Subject: [PATCH 2/5] Remove unnecessary repairing constant --- src/phpunit/includes/install.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/phpunit/includes/install.php b/src/phpunit/includes/install.php index 912d8a4..45c0d60 100644 --- a/src/phpunit/includes/install.php +++ b/src/phpunit/includes/install.php @@ -24,7 +24,6 @@ tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter_exit' ); -define( 'WP_REPAIRING', true ); require_once ABSPATH . '/wp-settings.php'; require_once ABSPATH . '/wp-admin/includes/upgrade.php'; From 3e916dd391239ef4aa53346e8a3c01863d8a4dfb Mon Sep 17 00:00:00 2001 From: Mikko Saari Date: Fri, 28 Jan 2022 08:54:16 +0200 Subject: [PATCH 3/5] Renames rask -> msaari in composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 11cb181..0570864 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,16 @@ { - "name": "rask/wp-test-framework", + "name": "msaari/wp-test-framework", "description": "Extracted library from WordPress PHPUnit framework to aid in integration testing of plugins and themes", "type": "library", "keywords": ["wordpress", "testing", "tests", "phpunit"], "license": "GPL-3.0-or-later", "support": { - "source": "https://github.com/rask/wp-test-framework" + "source": "https://github.com/msaari/wp-test-framework" }, "autoload": { "psr-4": { - "rask\\WpTestFramework\\": "src/" + "msaari\\WpTestFramework\\": "src/" } }, From b767144bd6f18deedc7a6869627b76b83cedf686 Mon Sep 17 00:00:00 2001 From: Mikko Saari Date: Fri, 28 Jan 2022 12:52:21 +0200 Subject: [PATCH 4/5] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 995cb5d..bb65970 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The sources are updated when needed, so there may be minor differences between t This library should be installed as a Composer dependency inside your plugin or theme: - $ composer require --dev rask/wp-test-framework + $ composer require --dev msaari/wp-test-framework ### WordPress testing installation setup @@ -34,7 +34,7 @@ Inside your plugin/theme directory you need to setup PHPUnit. Any regular-ish `p require_once './vendor/autoload.php'; - \rask\WpTestFramework\Framework::load(); + \msaari\WpTestFramework\Framework::load(); Then you should load your plugin or theme. In the same bootstrap file you can do the following: @@ -42,7 +42,7 @@ Then you should load your plugin or theme. In the same bootstrap file you can do require_once './vendor/autoload.php'; - \rask\WpTestFramework\Framework::load(); + \msaari\WpTestFramework\Framework::load(); // Load your plugin From 7343a860249306e3280eb1440fbf518776958845 Mon Sep 17 00:00:00 2001 From: Mikko Saari Date: Fri, 28 Jan 2022 12:52:34 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb65970..d23499e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# rask/wp-test-framework +# msaari/wp-test-framework Extracted and librarized version of WordPress core's PHPUnit test framework to help with writing integration tests in WordPress plugins and themes.