Make WordPress Core


Ignore:
Timestamp:
11/18/2013 08:44:34 PM (11 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/option/blogOption.php

    r25397 r26252  
    66 */
    77class Tests_Option_BlogOption extends WP_UnitTestCase {
     8    protected $suppress = false;
     9
    810    function setUp() {
     11        global $wpdb;
    912        parent::setUp();
     13        $this->suppress = $wpdb->suppress_errors();
    1014
    1115        $_SERVER['REMOTE_ADDR'] = null;
     16    }
     17
     18    function tearDown() {
     19        global $wpdb;
     20        parent::tearDown();
     21        $wpdb->suppress_errors( $this->suppress );
    1222    }
    1323
Note: See TracChangeset for help on using the changeset viewer.