From e52333e5f31108e14bd9fdb5dc73846ec0410012 Mon Sep 17 00:00:00 2001 From: WP <34419856+wp-phpunit-bot@users.noreply.github.com> Date: Fri, 13 Dec 2019 13:23:00 +0000 Subject: [PATCH 1/5] Building 5.3.1 --- data/images/one-blue-pixel-1-100x100.png | Bin 0 -> 320 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/images/one-blue-pixel-1-100x100.png diff --git a/data/images/one-blue-pixel-1-100x100.png b/data/images/one-blue-pixel-1-100x100.png new file mode 100644 index 0000000000000000000000000000000000000000..1aff0e0ca08b61b27f1e6a41b58368249c65f430 GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0vp^DIm!lvI6;>1s;*b3=DjSL74G){tA%xtDY{7Ar*0NFBmd1FmN1D_&xm^*SmI(GiN?6 v(V8H7f-8k}6H{d48iz0i?V-Z0x^4SRdH;OnS;uYxJ;>nc>gTe~DWM4fmXc+` literal 0 HcmV?d00001 From 1a259ef981c1ac3eaf07794eb42998b447bfe995 Mon Sep 17 00:00:00 2001 From: WP <34419856+wp-phpunit-bot@users.noreply.github.com> Date: Thu, 30 Apr 2020 14:51:08 +0000 Subject: [PATCH 2/5] Building 5.3.3 --- includes/abstract-testcase.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/includes/abstract-testcase.php b/includes/abstract-testcase.php index 9c586ee..1eda86c 100644 --- a/includes/abstract-testcase.php +++ b/includes/abstract-testcase.php @@ -186,16 +186,15 @@ public function clean_up_global_scope() { * we want to skip tests that only need to run for master. */ public function skipOnAutomatedBranches() { - // gentenv can be disabled - if ( ! function_exists( 'getenv' ) ) { - return false; - } - // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables $travis_branch = getenv( 'TRAVIS_BRANCH' ); $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' ); - if ( false !== $travis_pull_request && 'master' !== $travis_branch ) { + if ( ! $travis_branch || ! $travis_pull_request ) { + return; + } + + if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) { $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' ); } } From 0d7e8a3a810f45d48d12d1cd58edfa1e28396294 Mon Sep 17 00:00:00 2001 From: WP <34419856+wp-phpunit-bot@users.noreply.github.com> Date: Thu, 15 Apr 2021 17:53:40 +0000 Subject: [PATCH 3/5] Building 5.3.7 --- includes/abstract-testcase.php | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/includes/abstract-testcase.php b/includes/abstract-testcase.php index 1eda86c..bc2c909 100644 --- a/includes/abstract-testcase.php +++ b/includes/abstract-testcase.php @@ -180,7 +180,7 @@ public function clean_up_global_scope() { } /** - * Allow tests to be skipped on some automated runs + * Allow tests to be skipped on some automated runs. * * For test runs on Travis for something other than trunk/master * we want to skip tests that only need to run for master. @@ -221,6 +221,29 @@ public function skipWithMultisite() { } } + /** + * Allow tests to be skipped if the HTTP request times out. + * + * @param array|WP_Error $response HTTP response. + */ + public function skipTestOnTimeout( $response ) { + if ( ! is_wp_error( $response ) ) { + return; + } + if ( 'connect() timed out!' === $response->get_error_message() ) { + $this->markTestSkipped( 'HTTP timeout' ); + } + + if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) { + $this->markTestSkipped( 'HTTP timeout' ); + } + + if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) { + $this->markTestSkipped( 'HTTP timeout' ); + } + + } + /** * Unregister existing post types and register defaults. * @@ -1201,4 +1224,26 @@ protected function update_post_modified( $post_id, $date ) { ) ); } + + /** + * Touches the given file and its directory if it doesn't already exist. + * + * This can be used to ensure a file that is implictly relied on in a test exists + * without it having to be built. + * + * @param string $file The file name. + */ + public static function touch( $file ) { + if ( file_exists( $file ) ) { + return; + } + + $dir = dirname( $file ); + + if ( ! file_exists( $dir ) ) { + mkdir( $dir, 0777, true ); + } + + touch( $file ); + } } From 39d7c19f91c70814623a5fc2c2bc992ceed4be3b Mon Sep 17 00:00:00 2001 From: WP <34419856+wp-phpunit-bot@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:49:25 +0000 Subject: [PATCH 4/5] Building 5.3.10 --- includes/bootstrap.php | 107 ++++++++++++++++++++++++++++ includes/phpunit7/testcase.php | 123 +++++++++++++++++++++++++++++---- includes/testcase.php | 123 +++++++++++++++++++++++++++++---- 3 files changed, 323 insertions(+), 30 deletions(-) diff --git a/includes/bootstrap.php b/includes/bootstrap.php index 97003ae..e25e73e 100644 --- a/includes/bootstrap.php +++ b/includes/bootstrap.php @@ -51,6 +51,113 @@ exit( 1 ); } +/* + * Load the PHPUnit Polyfills autoloader. + * + * The PHPUnit Polyfills are a requirement for the WP test suite. + * + * For running the Core tests, the Make WordPress Core handbook contains step-by-step instructions + * on how to get up and running for a variety of supported workflows: + * {@link https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/#test-running-workflow-options} + * + * Plugin/theme integration tests can handle this in any of the following ways: + * - When using a full WP install: run `composer install` for the WP install prior to running the tests. + * - When using a partial WP test suite install: + * - Add a `yoast/phpunit-polyfills` (dev) requirement to the plugin/theme's own `composer.json` file. + * - And then: + * - Either load the PHPUnit Polyfills autoload file prior to running the WP core bootstrap file. + * - Or declare a `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant containing the absolute path to the + * root directory of the PHPUnit Polyfills installation. + * If the constant is used, it is strongly recommended to declare this constant in the plugin/theme's + * own test bootstrap file. + * The constant MUST be declared prior to calling this file. + */ +if ( ! class_exists( 'Yoast\PHPUnitPolyfills\Autoload' ) ) { + // Default location of the autoloader for WP core test runs. + $phpunit_polyfills_autoloader = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; + $phpunit_polyfills_error = false; + + // Allow for a custom installation location to be provided for plugin/theme integration tests. + if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { + $phpunit_polyfills_path = WP_TESTS_PHPUNIT_POLYFILLS_PATH; + + if ( is_string( WP_TESTS_PHPUNIT_POLYFILLS_PATH ) + && '' !== WP_TESTS_PHPUNIT_POLYFILLS_PATH + ) { + // Be tolerant to the path being provided including the filename. + if ( substr( $phpunit_polyfills_path, -29 ) !== 'phpunitpolyfills-autoload.php' ) { + $phpunit_polyfills_path = rtrim( $phpunit_polyfills_path, '/\\' ); + $phpunit_polyfills_path = $phpunit_polyfills_path . '/phpunitpolyfills-autoload.php'; + } + + $phpunit_polyfills_autoloader = $phpunit_polyfills_path; + } else { + $phpunit_polyfills_error = true; + } + } + + if ( $phpunit_polyfills_error || ! file_exists( $phpunit_polyfills_autoloader ) ) { + echo 'Error: The PHPUnit Polyfills library is a requirement for running the WP test suite.' . PHP_EOL; + if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { + printf( + 'The PHPUnit Polyfills autoload file was not found in "%s"' . PHP_EOL, + WP_TESTS_PHPUNIT_POLYFILLS_PATH + ); + echo 'Please verify that the file path provided in the WP_TESTS_PHPUNIT_POLYFILLS_PATH constant is correct.' . PHP_EOL; + echo 'The WP_TESTS_PHPUNIT_POLYFILLS_PATH constant should contain an absolute path to the root directory' + . ' of the PHPUnit Polyfills library.' . PHP_EOL; + } elseif ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { + echo 'You need to run `composer install` before running the tests.' . PHP_EOL; + echo 'Once the dependencies are installed, you can run the tests using the Composer-installed version' + . ' of PHPUnit or using a PHPUnit phar file, but the dependencies do need to be installed' + . ' whichever way the tests are run.' . PHP_EOL; + } else { + echo 'If you are trying to run plugin/theme integration tests, make sure the PHPUnit Polyfills library' + . ' (https://github.com/Yoast/PHPUnit-Polyfills) is available and either load the autoload file' + . ' of this library in your own test bootstrap before calling the WP Core test bootstrap file;' + . ' or set the absolute path to the PHPUnit Polyfills library in a "WP_TESTS_PHPUNIT_POLYFILLS_PATH"' + . ' constant to allow the WP Core bootstrap to load the Polyfills.' . PHP_EOL . PHP_EOL; + echo 'If you are trying to run the WP Core tests, make sure to set the "WP_RUN_CORE_TESTS" constant' + . ' to 1 and run `composer install` before running the tests.' . PHP_EOL; + echo 'Once the dependencies are installed, you can run the tests using the Composer-installed' + . ' version of PHPUnit or using a PHPUnit phar file, but the dependencies do need to be' + . ' installed whichever way the tests are run.' . PHP_EOL; + } + exit( 1 ); + } + + require_once $phpunit_polyfills_autoloader; +} +unset( $phpunit_polyfills_autoloader, $phpunit_polyfills_error, $phpunit_polyfills_path ); + +/* + * Minimum version of the PHPUnit Polyfills package as declared in `composer.json`. + * Only needs updating when new polyfill features start being used in the test suite. + */ +$phpunit_polyfills_minimum_version = '1.0.1'; +if ( class_exists( '\Yoast\PHPUnitPolyfills\Autoload' ) + && ( defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) === false + || version_compare( Yoast\PHPUnitPolyfills\Autoload::VERSION, $phpunit_polyfills_minimum_version, '<' ) ) +) { + printf( + 'Error: Version mismatch detected for the PHPUnit Polyfills.' + . ' Please ensure that PHPUnit Polyfills %s or higher is loaded. Found version: %s' . PHP_EOL, + $phpunit_polyfills_minimum_version, + defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) ? Yoast\PHPUnitPolyfills\Autoload::VERSION : '1.0.0 or lower' + ); + if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { + printf( + 'Please ensure that the PHPUnit Polyfill installation in "%s" is updated to version %s or higher.' . PHP_EOL, + WP_TESTS_PHPUNIT_POLYFILLS_PATH, + $phpunit_polyfills_minimum_version + ); + } elseif ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { + echo 'Please run `composer install` to install the latest version.' . PHP_EOL; + } + exit( 1 ); +} +unset( $phpunit_polyfills_minimum_version ); + tests_reset__SERVER(); define( 'WP_TESTS_TABLE_PREFIX', $table_prefix ); diff --git a/includes/phpunit7/testcase.php b/includes/phpunit7/testcase.php index 9edc885..2c1b3dc 100644 --- a/includes/phpunit7/testcase.php +++ b/includes/phpunit7/testcase.php @@ -1,6 +1,22 @@ set_up(); } + + /** + * Wrapper method for the `tear_down()` method for forward-compatibility with WP 5.9. + */ + public function tearDown() { + $this->tear_down(); + parent::tearDown(); + } + + /** + * Wrapper method for the `assert_pre_conditions()` method for forward-compatibility with WP 5.9. + */ + protected function assertPreConditions() { + parent::assertPreConditions(); + $this->assert_pre_conditions(); + } + + /** + * Wrapper method for the `assert_post_conditions()` method for forward-compatibility with WP 5.9. + */ + protected function assertPostConditions() { + parent::assertPostConditions(); + $this->assert_post_conditions(); + } + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + public static function set_up_before_class() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + public static function tear_down_after_class() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function set_up() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function tear_down() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function assert_pre_conditions() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function assert_post_conditions() {} } diff --git a/includes/testcase.php b/includes/testcase.php index 964af64..d489974 100644 --- a/includes/testcase.php +++ b/includes/testcase.php @@ -1,6 +1,22 @@ set_up(); } + + /** + * Wrapper method for the `tear_down()` method for forward-compatibility with WP 5.9. + */ + public function tearDown() { + $this->tear_down(); + parent::tearDown(); + } + + /** + * Wrapper method for the `assert_pre_conditions()` method for forward-compatibility with WP 5.9. + */ + protected function assertPreConditions() { + parent::assertPreConditions(); + $this->assert_pre_conditions(); + } + + /** + * Wrapper method for the `assert_post_conditions()` method for forward-compatibility with WP 5.9. + */ + protected function assertPostConditions() { + parent::assertPostConditions(); + $this->assert_post_conditions(); + } + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + public static function set_up_before_class() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + public static function tear_down_after_class() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function set_up() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function tear_down() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function assert_pre_conditions() {} + + /** + * Placeholder method for forward-compatibility with WP 5.9. + */ + protected function assert_post_conditions() {} } From 941f8c7d8f41660df120775cc15d9870c76f5dd7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 6 Aug 2025 01:26:06 +0000 Subject: [PATCH 5/5] Building 5.3.19 --- includes/abstract-testcase.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/includes/abstract-testcase.php b/includes/abstract-testcase.php index bc2c909..d1936a9 100644 --- a/includes/abstract-testcase.php +++ b/includes/abstract-testcase.php @@ -180,22 +180,23 @@ public function clean_up_global_scope() { } /** - * Allow tests to be skipped on some automated runs. + * Allows tests to be skipped on some automated runs. * - * For test runs on Travis for something other than trunk/master - * we want to skip tests that only need to run for master. + * For test runs on GitHub Actions for something other than trunk, + * we want to skip tests that only need to run for trunk. */ public function skipOnAutomatedBranches() { - // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables - $travis_branch = getenv( 'TRAVIS_BRANCH' ); - $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' ); + // https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables + $github_event_name = getenv( 'GITHUB_EVENT_NAME' ); + $github_ref = getenv( 'GITHUB_REF' ); - if ( ! $travis_branch || ! $travis_pull_request ) { - return; - } + if ( $github_event_name ) { + // We're on GitHub Actions. + $skipped = array( 'pull_request', 'pull_request_target' ); - if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) { - $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' ); + if ( in_array( $github_event_name, $skipped, true ) || 'refs/heads/trunk' !== $github_ref ) { + $this->markTestSkipped( 'For automated test runs, this test is only run on trunk' ); + } } }