REST API: Make plugin installation tests more robust on alternate test environments.

The REST API plugin installation tests use the `upgrader_pre_download` filter to avoid downloading the test plugin from WordPress.org. Previously, this would apply to any upgrader, which caused issues if the testing environment required a language update.

Now, the filter only overwrites the file if the `Plugin_Upgrader` is being used which should hopefully prevent the issue.

Props pfefferle, TimothyBlynJacobs.
Fixes #50671.


git-svn-id: https://develop.svn.wordpress.org/trunk@48524 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Timothy Jacobs 2020-07-21 01:36:16 +00:00
parent 60d339cfde
commit 2daa951685

View File

@ -1013,9 +1013,15 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
copy( DIR_TESTDATA . '/plugins/link-manager.zip', DIR_TESTDATA . '/link-manager.zip' ); copy( DIR_TESTDATA . '/plugins/link-manager.zip', DIR_TESTDATA . '/link-manager.zip' );
add_filter( add_filter(
'upgrader_pre_download', 'upgrader_pre_download',
function () { static function ( $reply, $package, $upgrader ) {
return DIR_TESTDATA . '/link-manager.zip'; if ( $upgrader instanceof Plugin_Upgrader ) {
} $reply = DIR_TESTDATA . '/link-manager.zip';
}
return $reply;
},
10,
3
); );
} }