From b48e2addebc6c7260c8c2a283439bcd451f59fee Mon Sep 17 00:00:00 2001 From: Adrian Duffell <9312929+adrianduffell@users.noreply.github.com> Date: Fri, 26 Mar 2021 21:52:54 +0800 Subject: [PATCH] Fix Database Table Creation Test (https://github.com/woocommerce/woocommerce-admin/pull/6670) * Fix mistake in documentation * Fix typo in query * Fix a bug where the tables were not being dropped --- plugins/woocommerce-admin/tests/install.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce-admin/tests/install.php b/plugins/woocommerce-admin/tests/install.php index 70939bfe6a6..e639263d63d 100644 --- a/plugins/woocommerce-admin/tests/install.php +++ b/plugins/woocommerce-admin/tests/install.php @@ -20,7 +20,11 @@ class WC_Admin_Tests_Install extends WP_UnitTestCase { function test_create_tables() { global $wpdb; - // List of tables created by Install::test_create_tables. + // Remove the Test Suiteā€™s use of temporary tables https://wordpress.stackexchange.com/a/220308 + remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); + remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); + + // List of tables created by Install::create_tables. $tables = array( "{$wpdb->prefix}wc_order_stats", "{$wpdb->prefix}wc_order_product_lookup", @@ -33,7 +37,7 @@ class WC_Admin_Tests_Install extends WP_UnitTestCase { ); // Remove any existing tables in the environment. - $query = 'DROP TABLES IF EXISTS' . implode( ',', $tables ); + $query = 'DROP TABLE IF EXISTS ' . implode( ',', $tables ); $wpdb->query( $query ); // Try to create the tables.