diff --git a/CHANGELOG.md b/CHANGELOG.md index 0479e02c5..28324ac2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- Ensure the `WPLoader` module will initialize correctly when used in `loadOnly` mode not using the `EventDispatcherBridge` extension. +- Ensure the `WPLoader` module will initialize correctly when used in `loadOnly` mode not using the `EventDispatcherBridge` extension. (thanks @lxbdr) +- Support loading the `wpdb` class from either the `class-wpdb.php` file or the `wp-db.php` one, supporting older versions of WordPress (thanks @BrianHenryIE) ## [4.2.5] 2024-06-26; diff --git a/bin/update_core_phpunit_includes b/bin/update_core_phpunit_includes index 5e2c82b3e..f0943fe5a 100755 --- a/bin/update_core_phpunit_includes +++ b/bin/update_core_phpunit_includes @@ -16,6 +16,7 @@ rm -rf "${root_dir}"/includes/core-phpunit/includes && cd .. && mv wordpress-develop/tests/phpunit/includes ./includes && rm -rf wordpress-develop && + git apply "${root_dir}"/config/patches/core-phpunit/includes/install.php.patch && git apply "${root_dir}"/config/patches/core-phpunit/includes/abstract-testcase.php.patch && git apply "${root_dir}"/config/patches/core-phpunit/includes/testcase-ajax.php.patch && git apply "${root_dir}"/config/patches/core-phpunit/includes/testcase-canonical.php.patch && diff --git a/config/patches/core-phpunit/includes/install.php.patch b/config/patches/core-phpunit/includes/install.php.patch new file mode 100644 index 000000000..cb9872f17 --- /dev/null +++ b/config/patches/core-phpunit/includes/install.php.patch @@ -0,0 +1,23 @@ +diff --git a/includes/core-phpunit/includes/install.php b/includes/core-phpunit/includes/install.php +index 8a595903..dbb13b5f 100644 +--- a/includes/core-phpunit/includes/install.php ++++ b/includes/core-phpunit/includes/install.php +@@ -40,8 +40,17 @@ + require_once ABSPATH . 'wp-settings.php'; + + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; +-require_once ABSPATH . 'wp-includes/class-wpdb.php'; + ++/** ++ * File was renamed in WordPress 6.1. ++ * ++ * @see https://core.trac.wordpress.org/ticket/56268 ++ * @see https://github.com/WordPress/WordPress/commit/8484c7babb6b6ee951f83babea656a294157665d ++ */ ++require_once file_exists( ABSPATH . 'wp-includes/class-wpdb.php' ) ++ ? ABSPATH . 'wp-includes/class-wpdb.php' ++ : ABSPATH . 'wp-includes/wp-db.php'; ++ + // Override the PHPMailer. + global $phpmailer; + require_once __DIR__ . '/mock-mailer.php'; diff --git a/includes/core-phpunit/includes/install.php b/includes/core-phpunit/includes/install.php index 8a595903c..dbb13b5f0 100644 --- a/includes/core-phpunit/includes/install.php +++ b/includes/core-phpunit/includes/install.php @@ -40,8 +40,17 @@ require_once ABSPATH . 'wp-settings.php'; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; -require_once ABSPATH . 'wp-includes/class-wpdb.php'; +/** + * File was renamed in WordPress 6.1. + * + * @see https://core.trac.wordpress.org/ticket/56268 + * @see https://github.com/WordPress/WordPress/commit/8484c7babb6b6ee951f83babea656a294157665d + */ +require_once file_exists( ABSPATH . 'wp-includes/class-wpdb.php' ) + ? ABSPATH . 'wp-includes/class-wpdb.php' + : ABSPATH . 'wp-includes/wp-db.php'; + // Override the PHPMailer. global $phpmailer; require_once __DIR__ . '/mock-mailer.php'; diff --git a/includes/core-phpunit/includes/testcase-rest-post-type-controller.php b/includes/core-phpunit/includes/testcase-rest-post-type-controller.php index 82be74b7d..553373bde 100644 --- a/includes/core-phpunit/includes/testcase-rest-post-type-controller.php +++ b/includes/core-phpunit/includes/testcase-rest-post-type-controller.php @@ -109,8 +109,10 @@ protected function check_post_data( $post, $data, $context, $links ) { // Check filtered values. if ( post_type_supports( $post->post_type, 'title' ) ) { add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); + add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); $this->assertSame( get_the_title( $post->ID ), $data['title']['rendered'] ); remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); + remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); if ( 'edit' === $context ) { $this->assertSame( $post->post_title, $data['title']['raw'] ); } else { diff --git a/tests/acceptance.suite.dist.yml b/tests/acceptance.suite.dist.yml index 093b617a3..38bf65850 100644 --- a/tests/acceptance.suite.dist.yml +++ b/tests/acceptance.suite.dist.yml @@ -23,7 +23,8 @@ modules: X_WPBROWSER_REQUEST: 1 X_TEST_REQUEST: 1 X_APM_REQUEST: 1 - connect_timeout: 3 + connect_timeout: 3.0 + timeout: 3.0 lucatume\WPBrowser\Module\WPDb: dsn: '%WORDPRESS_DB_DSN%' user: %WORDPRESS_DB_USER%