Revert most of 74a3f1d6

As @claudiosanches pointed out, there isn't much real-world need for `WC_Install::get_tables()` to sort results. Instead, sort the returned value within the `WC_Tests_Install::test_get_tables()` method.
This commit is contained in:
Steve Grunwell 2018-05-11 22:46:39 +00:00
parent 226aedd4e2
commit 317e7ba29f
2 changed files with 3 additions and 31 deletions

View File

@ -809,9 +809,6 @@ CREATE TABLE {$wpdb->prefix}woocommerce_termmeta (
*/
$tables = apply_filters( 'woocommerce_install_get_tables', $tables );
// Sort the tables alphabetically.
sort( $tables );
return $tables;
}

View File

@ -122,8 +122,10 @@ class WC_Tests_Install extends WC_Unit_Test_Case {
$tables = $wpdb->get_col(
"SHOW TABLES WHERE `Tables_in_{$wpdb->dbname}` LIKE '{$wpdb->prefix}woocommerce\_%' OR `Tables_in_{$wpdb->dbname}` LIKE '{$wpdb->prefix}wc\_%'"
);
$result = WC_Install::get_tables();
sort( $result );
$this->assertEquals( $tables, WC_Install::get_tables() );
$this->assertEquals( $tables, $result );
}
/**
@ -146,31 +148,4 @@ class WC_Tests_Install extends WC_Unit_Test_Case {
return $tables;
}
/**
* Test - WC_Install::get_tables() should sort tables alphabetically.
*/
public function test_get_tables_sorts_results() {
global $wpdb;
add_filter( 'woocommerce_install_get_tables', array( $this, 'append_tables_for_sorting' ) );
$sorted = WC_Install::get_tables();
sort( $sorted );
$this->assertEquals( $sorted, WC_Install::get_tables() );
}
/**
* Filter callback for test_get_tables_sorts_results().
*/
public function append_tables_for_sorting( $tables ) {
global $wpdb;
$tables[] = "{$wpdb->prefix}wc_another_table";
$tables[] = "{$wpdb->prefix}woocommerce_another_one";
$tables[] = "{$wpdb->prefix}woocommerce_yet_another_table";
return $tables;
}
}