Skip to content

Commit 4a45fdb

Browse files
committed
Tests: Limit upload directory isolation to the Core test suite.
Preserve default upload paths for plugin and theme test suites. Only define and clean the dedicated uploads directory when `WP_RUN_CORE_TESTS` is enabled. Developed in: #15914 Props peterwilsoncc. See #63532. git-svn-id: https://develop.svn.wordpress.org/trunk@65409 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 748d6d3 commit 4a45fdb

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎tests/phpunit/includes/bootstrap.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,17 @@
250250
define( 'REST_TESTS_IMPOSSIBLY_HIGH_NUMBER', 99999999 );
251251

252252
/*
253+
* Isolate uploads in a dedicated directory when running the core test suite only,
254+
* so that plugins and themes using the test suite keep the default uploads location.
255+
*
253256
* Tests that cover the upload_path and upload_url_path options run in a separate process
254257
* with WP_TESTS_SKIP_UPLOADS_CONSTANT set, as UPLOADS overrides those options.
255258
*/
256-
if ( ! defined( 'UPLOADS' ) && '1' !== getenv( 'WP_TESTS_SKIP_UPLOADS_CONSTANT' ) ) {
259+
if (
260+
defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS
261+
&& ! defined( 'UPLOADS' )
262+
&& '1' !== getenv( 'WP_TESTS_SKIP_UPLOADS_CONSTANT' )
263+
) {
257264
define( 'UPLOADS', 'wp-content/test-suite-uploads' );
258265

259266
/*

‎tests/phpunit/includes/functions.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ function _upload_dir_https( $uploads ) {
360360
* @return string The upload URL.
361361
*/
362362
function _upload_get_url( $path = '', $scheme = 'http' ) {
363-
return $scheme . '://' . WP_TESTS_DOMAIN . '/' . trailingslashit( UPLOADS ) . ltrim( $path, '/' );
363+
$uploads = defined( 'UPLOADS' ) ? UPLOADS : 'wp-content/uploads';
364+
365+
return $scheme . '://' . WP_TESTS_DOMAIN . '/' . trailingslashit( $uploads ) . ltrim( $path, '/' );
364366
}
365367

366368
/**

0 commit comments

Comments
 (0)