@@ -622,9 +622,9 @@ private static function configure_sqlite( $dir ): void {
622622 * We cache the results of `wp core download` to improve test performance.
623623 * Ideally, we'd cache at the HTTP layer for more reliable tests.
624624 */
625- private static function cache_wp_files (): void {
626- $ wp_version = getenv ( 'WP_VERSION ' );
627- $ wp_version_suffix = ( false !== $ wp_version ) ? "- $ wp_version " : '' ;
625+ private static function cache_wp_files ( $ version = '' ): void {
626+ $ wp_version = $ version ?: getenv ( 'WP_VERSION ' );
627+ $ wp_version_suffix = ( false !== $ wp_version && '' !== $ wp_version ) ? "- $ wp_version " : '' ;
628628 self ::$ cache_dir = sys_get_temp_dir () . '/wp-cli-test-core-download-cache ' . $ wp_version_suffix ;
629629 self ::$ sqlite_cache_dir = sys_get_temp_dir () . '/wp-cli-test-sqlite-integration-cache ' ;
630630
@@ -1289,9 +1289,9 @@ public function add_line_to_wp_config( &$wp_config_code, $line ): void {
12891289 /**
12901290 * @param string $subdir
12911291 */
1292- public function download_wp ( $ subdir = '' ): void {
1292+ public function download_wp ( $ subdir = '' , $ version = '' ): void {
12931293 if ( ! self ::$ cache_dir ) {
1294- self ::cache_wp_files ();
1294+ self ::cache_wp_files ( $ version );
12951295
12961296 $ result = Process::create ( Utils \esc_cmd ( 'wp core version --debug --path=%s ' , self ::$ cache_dir ), null , self ::get_process_env_variables () )->run_check ();
12971297 echo "[Debug messages] \n" ;
@@ -1365,10 +1365,11 @@ public function create_config( $subdir = '', $extra_php = false ): void {
13651365
13661366 /**
13671367 * @param string $subdir
1368+ * @param string $version
13681369 */
1369- public function install_wp ( $ subdir = '' ): void {
1370- $ wp_version = getenv ( 'WP_VERSION ' );
1371- $ wp_version_suffix = ( false !== $ wp_version ) ? "- $ wp_version " : '' ;
1370+ public function install_wp ( $ subdir = '' , $ version = '' ): void {
1371+ $ wp_version = $ version ?: getenv ( 'WP_VERSION ' );
1372+ $ wp_version_suffix = ( false !== $ wp_version && '' !== $ wp_version ) ? "- $ wp_version " : '' ;
13721373 self ::$ install_cache_dir = sys_get_temp_dir () . '/wp-cli-test-core-install-cache ' . $ wp_version_suffix ;
13731374 if ( ! file_exists ( self ::$ install_cache_dir ) ) {
13741375 mkdir ( self ::$ install_cache_dir );
@@ -1383,7 +1384,7 @@ public function install_wp( $subdir = '' ): void {
13831384 $ this ->create_db ();
13841385 }
13851386 $ this ->create_run_dir ();
1386- $ this ->download_wp ( $ subdir );
1387+ $ this ->download_wp ( $ subdir, $ version );
13871388 $ this ->create_config ( $ subdir , $ config_extra_php );
13881389
13891390 $ install_args = [
0 commit comments