diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index 7e97dd55bc2b7..60911bc362ff4 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -250,10 +250,17 @@ define( 'REST_TESTS_IMPOSSIBLY_HIGH_NUMBER', 99999999 ); /* + * Isolate uploads in a dedicated directory when running the core test suite only, + * so that plugins and themes using the test suite keep the default uploads location. + * * Tests that cover the upload_path and upload_url_path options run in a separate process * with WP_TESTS_SKIP_UPLOADS_CONSTANT set, as UPLOADS overrides those options. */ -if ( ! defined( 'UPLOADS' ) && '1' !== getenv( 'WP_TESTS_SKIP_UPLOADS_CONSTANT' ) ) { +if ( + defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS + && ! defined( 'UPLOADS' ) + && '1' !== getenv( 'WP_TESTS_SKIP_UPLOADS_CONSTANT' ) +) { define( 'UPLOADS', 'wp-content/test-suite-uploads' ); /* diff --git a/tests/phpunit/includes/functions.php b/tests/phpunit/includes/functions.php index cc39bbc52a62d..a3c86e60aefa3 100644 --- a/tests/phpunit/includes/functions.php +++ b/tests/phpunit/includes/functions.php @@ -360,7 +360,9 @@ function _upload_dir_https( $uploads ) { * @return string The upload URL. */ function _upload_get_url( $path = '', $scheme = 'http' ) { - return $scheme . '://' . WP_TESTS_DOMAIN . '/' . trailingslashit( UPLOADS ) . ltrim( $path, '/' ); + $uploads = defined( 'UPLOADS' ) ? UPLOADS : 'wp-content/uploads'; + + return $scheme . '://' . WP_TESTS_DOMAIN . '/' . trailingslashit( $uploads ) . ltrim( $path, '/' ); } /**