Make WordPress Core

Changeset 28943


Ignore:
Timestamp:
07/01/2014 06:51:46 PM (12 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk/tests/phpunit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r28910 r28943  
    2424require_once $config_file_path;
    2525
     26define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
    2627define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' );
    2728
  • trunk/tests/phpunit/includes/testcase.php

    r27795 r28943  
    3636                $this->expectedDeprecated();
    3737                $wpdb->query( 'ROLLBACK' );
     38                if ( is_multisite() ) {
     39                        while ( ms_is_switched() ) {
     40                                restore_current_blog();
     41                        }
     42                }
    3843                $wp_query = new WP_Query();
    3944                $post = null;
  • trunk/tests/phpunit/tests/ms.php

    r28910 r28943  
    15111511         */
    15121512        function _setup_host_request( $domain, $path ) {
    1513                 global $current_site, $current_blog, $wpdb, $table_prefix;
    1514 
     1513                global $current_site, $current_blog, $table_prefix;
     1514
     1515                $table_prefix = WP_TESTS_TABLE_PREFIX;
    15151516                $current_site = $current_blog = null;
    15161517                $_SERVER['HTTP_HOST'] = $domain;
Note: See TracChangeset for help on using the changeset viewer.