Share fixtures across a number of query-related test classes.

This shaves 10-20 seconds off the running time for the suite.

See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@30276 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2014-11-08 15:29:31 +00:00
parent a4ecf4b080
commit fe726039bd
3 changed files with 114 additions and 50 deletions

View File

@@ -167,6 +167,16 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
add_filter( 'query', array( $this, '_drop_temporary_tables' ) );
}
/**
* Commit the queries in a transaction.
*
* @since 4.1.0
*/
public static function commit_transaction() {
global $wpdb;
$wpdb->query( 'COMMIT;' );
}
function _create_temporary_tables( $query ) {
if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) )
return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 );