From 679fbbc422286fe0be97980301675aabee600923 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 24 Mar 2020 00:18:29 +0000 Subject: [PATCH] Build/Test Tools: Fix PHPUnit bootstrap to install WP from `/build` when tests are run with `npm run test`, `grunt test`, `grunt` then `phpunit`, etc. Fixes #49663. git-svn-id: https://develop.svn.wordpress.org/trunk@47496 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/bootstrap.php | 5 ++++- tests/phpunit/includes/install.php | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index ed0a35bc66..dcde8fd2ea 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -97,7 +97,10 @@ if ( file_exists( DIR_TESTDATA . '/themedir1' ) ) { } if ( '1' !== getenv( 'WP_TESTS_SKIP_INSTALL' ) ) { - system( WP_PHP_BINARY . ' ' . escapeshellarg( __DIR__ . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite, $retval ); + $core_tests = ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) ? 'run_core_tests' : 'no_core_tests'; + $ms_tests = $multisite ? 'run_ms_tests' : 'no_ms_tests'; + + system( WP_PHP_BINARY . ' ' . escapeshellarg( __DIR__ . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $ms_tests . ' ' . $core_tests, $retval ); if ( 0 !== $retval ) { exit( $retval ); } diff --git a/tests/phpunit/includes/install.php b/tests/phpunit/includes/install.php index cad83c7414..4ab457f48a 100644 --- a/tests/phpunit/includes/install.php +++ b/tests/phpunit/includes/install.php @@ -7,7 +7,11 @@ error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT ); $config_file_path = $argv[1]; -$multisite = ! empty( $argv[2] ); +$multisite = in_array( 'run_ms_tests', $argv, true ); + +if ( ! defined( 'WP_RUN_CORE_TESTS' ) && in_array( 'run_core_tests', $argv, true ) ) { + define( 'WP_RUN_CORE_TESTS', true ); +} define( 'WP_INSTALLING', true ); require_once $config_file_path;