Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/phpunit/includes/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

/*
Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/' );
}

/**
Expand Down
Loading