mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Tests: Ensure meta keys are cleaned up after each test.
Props jnylen0. Fixes #46007. git-svn-id: https://develop.svn.wordpress.org/trunk@44633 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -167,6 +167,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
$GLOBALS[ $global ] = null;
|
||||
}
|
||||
|
||||
$this->unregister_all_meta_keys();
|
||||
remove_theme_support( 'html5' );
|
||||
remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
|
||||
remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );
|
||||
@@ -330,6 +331,27 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up any registered meta keys.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @global array $wp_meta_keys
|
||||
*/
|
||||
function unregister_all_meta_keys() {
|
||||
global $wp_meta_keys;
|
||||
if ( ! is_array( $wp_meta_keys ) ) {
|
||||
return;
|
||||
}
|
||||
foreach ( $wp_meta_keys as $object_type => $type_keys ) {
|
||||
foreach ( $type_keys as $object_subtype => $subtype_keys ) {
|
||||
foreach ( $subtype_keys as $key => $value ) {
|
||||
unregister_meta_key( $object_type, $key, $object_subtype );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function start_transaction() {
|
||||
global $wpdb;
|
||||
$wpdb->query( 'SET autocommit = 0;' );
|
||||
|
||||
Reference in New Issue
Block a user