Avoid polluted $table_prefix
and $_wp_switched_stack
in multisite unit tests.
Add `WP_TESTS_TABLE_PREFIX` in `bootstrap.php` to ensure the original value for `$table_prefix` is always available. Props jeremyfelt. Fixes #28692. git-svn-id: https://develop.svn.wordpress.org/trunk@28943 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
99d75b6acb
commit
9ab7f4b144
@ -23,6 +23,7 @@ if ( !is_readable( $config_file_path ) ) {
|
||||
}
|
||||
require_once $config_file_path;
|
||||
|
||||
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
|
||||
define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' );
|
||||
|
||||
if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) )
|
||||
|
@ -35,6 +35,11 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
global $wpdb, $wp_query, $post;
|
||||
$this->expectedDeprecated();
|
||||
$wpdb->query( 'ROLLBACK' );
|
||||
if ( is_multisite() ) {
|
||||
while ( ms_is_switched() ) {
|
||||
restore_current_blog();
|
||||
}
|
||||
}
|
||||
$wp_query = new WP_Query();
|
||||
$post = null;
|
||||
remove_theme_support( 'html5' );
|
||||
|
@ -1510,8 +1510,9 @@ class Tests_MS extends WP_UnitTestCase {
|
||||
* @param string $path REQUEST_URI of the boot strap request.
|
||||
*/
|
||||
function _setup_host_request( $domain, $path ) {
|
||||
global $current_site, $current_blog, $wpdb, $table_prefix;
|
||||
global $current_site, $current_blog, $table_prefix;
|
||||
|
||||
$table_prefix = WP_TESTS_TABLE_PREFIX;
|
||||
$current_site = $current_blog = null;
|
||||
$_SERVER['HTTP_HOST'] = $domain;
|
||||
$_SERVER['REQUEST_URI'] = $path;
|
||||
|
Loading…
Reference in New Issue
Block a user