WP_UnitTestCase::tearDownAfterClass() -> “mysqli_query(): Couldn’t fetch mysqli”
-
Hi there,
I’ve been getting an error with the test tool (https://develop.svn.www.ads-software.com/tags/4.7/tests/phpunit/includes/) of WordPress 4.7. The error never occurred with the one bundled with v4.6 or below (https://develop.svn.www.ads-software.com/tags/4.6.1/tests/phpunit/includes/).
The
tearDownAfterClass()
method of theWP_UnitTestCase
class produces the following error.[PHPUnit_Framework_Exception] mysqli_query(): Couldn't fetch mysqli
This is the function call trace which results in the error.
mysqli_query() at wp-test\wp-includes\wp-db.php:1877 wpdb->_do_query() at wp-test\wp-includes\wp-db.php:1765 wpdb->query() at wp-test\wordpress-tests-lib\includes\functions.php:65 _delete_all_data() at wp-test\wordpress-tests-lib\includes\testcase.php:76 WP_UnitTestCase::tearDownAfterClass() at n/a:n/a
This does not occur with the one that comes with v4.6 or below.
The code of the method from v4.6.
public static function tearDownAfterClass() { parent::tearDownAfterClass(); $c = self::get_called_class(); if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) { return; } call_user_func( array( $c, 'wpTearDownAfterClass' ) ); self::commit_transaction(); }
The code of the method from v4.7.
public static function tearDownAfterClass() { parent::tearDownAfterClass(); _delete_all_data(); self::flush_cache(); $c = self::get_called_class(); if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) { self::commit_transaction(); return; } call_user_func( array( $c, 'wpTearDownAfterClass' ) ); self::commit_transaction(); }
Looks like
_delete_all_data(); self::flush_cache();
is something to do with it. I wonder if others don’t get the error.
Does anybody have a clue?
- The topic ‘WP_UnitTestCase::tearDownAfterClass() -> “mysqli_query(): Couldn’t fetch mysqli”’ is closed to new replies.