From e07424147ca8f4e959249734173d634f9146ecc9 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 3 Feb 2014 22:39:47 +0000 Subject: [PATCH] Test suite: Trim queries before deciding whether to create temporary tables. props jdgrimes. fixes #24800. git-svn-id: https://develop.svn.wordpress.org/trunk@27086 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index f8a21cd31a..7cd7148296 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -35,8 +35,8 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { global $wpdb; $this->expectedDeprecated(); $wpdb->query( 'ROLLBACK' ); - remove_filter( 'query', array( $this, '_create_temporary_table' ) ); - remove_filter( 'query', array( $this, '_drop_temporary_table' ) ); + remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); + remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); } @@ -64,19 +64,19 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { global $wpdb; $wpdb->query( 'SET autocommit = 0;' ); $wpdb->query( 'START TRANSACTION;' ); - add_filter( 'query', array( $this, '_create_temporary_table' ) ); - add_filter( 'query', array( $this, '_drop_temporary_table' ) ); + add_filter( 'query', array( $this, '_create_temporary_tables' ) ); + add_filter( 'query', array( $this, '_drop_temporary_tables' ) ); } - function _create_temporary_table( $query ) { - if ( 'CREATE TABLE' === substr( $query, 0, 12 ) ) - return substr_replace( $query, 'CREATE TEMPORARY TABLE', 0, 12 ); + function _create_temporary_tables( $query ) { + if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) + return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); return $query; } - function _drop_temporary_table( $query ) { - if ( 'DROP TABLE' === substr( $query, 0, 10 ) ) - return substr_replace( $query, 'DROP TEMPORARY TABLE', 0, 10 ); + function _drop_temporary_tables( $query ) { + if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) + return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); return $query; }