From 4ddaf4b5dff0893be6b571d351eb59db78f5b937 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 3 Nov 2020 21:07:33 +0000 Subject: [PATCH] Build/Test Tools: Disable update attempts while running unit tests. This fixes an issue introduced in [49369] that causes l10n related tests to fail when the PHPUnit test suite is run multiple times without hints of the site being under version control. [49369] removed the `.git` folder from the ZIP artifact created during the initial setup job. This ZIP file is used by the later jobs in the workflow that run the test suite. The absence of the `.git` folder in these later jobs caused the language packs initially loaded from `phpunit/data/languages` folder to be updated asynchronously, resulting in unexpected values when running the tests a second time. This change disables all Core auto-update and asynchronous language pack update attempts when running PHPUnit tests. Props ocean90, SergeyBiryukov. See #50401. Fixes #51670. git-svn-id: https://develop.svn.wordpress.org/trunk@49491 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index 65c1c370c4..876c81941e 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -144,6 +144,10 @@ $GLOBALS['_wp_die_disabled'] = false; tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' ); // Use the Spy REST Server instead of default. tests_add_filter( 'wp_rest_server_class', '_wp_rest_server_class_filter' ); +// Prevent updating translations asynchronously. +tests_add_filter( 'async_update_translation', '__return_false' ); +// Disable background updates. +tests_add_filter( 'automatic_updater_disabled', '__return_true' ); // Preset WordPress options defined in bootstrap file. // Used to activate themes, plugins, as well as other settings.