diff --git a/tests/phpunit/tests/admin/wpAutomaticUpdater.php b/tests/phpunit/tests/admin/wpAutomaticUpdater.php index 1746d9490c9db..18ea4d6febe87 100644 --- a/tests/phpunit/tests/admin/wpAutomaticUpdater.php +++ b/tests/phpunit/tests/admin/wpAutomaticUpdater.php @@ -609,8 +609,17 @@ public function test_is_allowed_dir_should_return_true_if_open_basedir_is_set_an $abspath_grandparent = trailingslashit( dirname( $abspath_parent ) ); $open_basedir_backup = ini_get( 'open_basedir' ); + + /* + * Windows must use a semi-colon as a separator. + * For all other operating systems, a colon should be used. + * + * See https://www.php.net/manual/en/ini.core.php#ini.open-basedir + */ + $separator = 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ? ';' : ':'; + // Allow access to the directory one level above the repository. - ini_set( 'open_basedir', wp_normalize_path( $abspath_grandparent ) ); + ini_set( 'open_basedir', sys_get_temp_dir() . $separator . wp_normalize_path( $abspath_grandparent ) ); // Checking an allowed directory should succeed. $actual = self::$updater->is_allowed_dir( wp_normalize_path( ABSPATH ) ); @@ -644,8 +653,17 @@ public function test_is_allowed_dir_should_return_false_if_open_basedir_is_set_a $abspath_grandparent = trailingslashit( dirname( $abspath_parent ) ); $open_basedir_backup = ini_get( 'open_basedir' ); + + /* + * Windows must use a semi-colon as a separator. + * For all other operating systems, a colon should be used. + * + * See https://www.php.net/manual/en/ini.core.php#ini.open-basedir + */ + $separator = 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ? ';' : ':'; + // Allow access to the directory one level above the repository. - ini_set( 'open_basedir', wp_normalize_path( $abspath_grandparent ) ); + ini_set( 'open_basedir', sys_get_temp_dir() . $separator . wp_normalize_path( $abspath_grandparent ) ); // Checking a directory not within the allowed path should trigger an `open_basedir` warning. $actual = self::$updater->is_allowed_dir( '/.git' );