mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
For unit tests that call wpmu_create_blog(), Blog factory, or installation code that attempts to clear transients: suppress database errors on setUp and restore on tearDown.
There are a few places in core that were preventing this from working by explicity setting `$wpdb->suppress_errors` to `false`. Instead, they should inherit the value that existed before errors were suppressed. This allows Multisite unit tests to run without explosive database errors, and allows `$wpdb->suppress_errors` to be overridden all the way down the chain. Fixes #26102. git-svn-id: https://develop.svn.wordpress.org/trunk@26252 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -9,13 +9,22 @@ if ( is_multisite() ) :
|
||||
*/
|
||||
class Tests_MS extends WP_UnitTestCase {
|
||||
protected $plugin_hook_count = 0;
|
||||
protected $suppress = false;
|
||||
|
||||
function setUp() {
|
||||
global $wpdb;
|
||||
parent::setUp();
|
||||
$this->suppress = $wpdb->suppress_errors();
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = '';
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
global $wpdb;
|
||||
parent::tearDown();
|
||||
$wpdb->suppress_errors( $this->suppress );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 22917
|
||||
*/
|
||||
@@ -105,9 +114,9 @@ class Tests_MS extends WP_UnitTestCase {
|
||||
$this->assertEquals( $details, wp_cache_get( $key, 'blog-lookup' ) );
|
||||
|
||||
foreach ( $wpdb->tables( 'blog', false ) as $table ) {
|
||||
$wpdb->suppress_errors();
|
||||
$suppress = $wpdb->suppress_errors();
|
||||
$table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
|
||||
$wpdb->suppress_errors( false );
|
||||
$wpdb->suppress_errors( $suppress );
|
||||
$this->assertNotEmpty( $table_fields );
|
||||
$result = $wpdb->get_results( "SELECT * FROM $prefix$table LIMIT 1" );
|
||||
if ( 'commentmeta' == $table || 'links' == $table )
|
||||
@@ -139,9 +148,9 @@ class Tests_MS extends WP_UnitTestCase {
|
||||
|
||||
$prefix = $wpdb->get_blog_prefix( $blog_id );
|
||||
foreach ( $wpdb->tables( 'blog', false ) as $table ) {
|
||||
$wpdb->suppress_errors();
|
||||
$suppress = $wpdb->suppress_errors();
|
||||
$table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
|
||||
$wpdb->suppress_errors( false );
|
||||
$wpdb->suppress_errors( $suppress );
|
||||
if ( $drop_tables )
|
||||
$this->assertEmpty( $table_fields );
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user