Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Refactor test suite #60

Merged
merged 8 commits into from
May 14, 2018
Merged

Refactor test suite #60

merged 8 commits into from
May 14, 2018

Conversation

stevegrunwell
Copy link
Contributor

This PR aims to solve a few issues that have come up in testing, with the hopes of making the test suite less fragile as WooCommerce evolves:

1. Return to using the official WooCommerce upstream

A number of our PRs have been merged into WooCommerce core, so there's no longer a need for our temporary feature/more-orders-tests branch.

2. Simplify the bootstrap file

Since the Custom Orders Table plugin relies on WooCommerce, let the WooCommerce core test suite bootstrap everything before we activate. This prevents incidents where, for example, a test run in isolation did not have access to the custom table.

3. Fix an improperly-nested else statement in WC_Order_Data_Store_Custom_Table::filter_database_queries()

This else statement was one level too high, causing issues when order queries were constructed with both customer_emails and customer_ids meta queries. Additional tests have been added around the method to prevent regressions.

4. Bump all Composer dependencies

We're only as good as the latest version of WooCommerce we're testing against.

Please note that there is one failing test, which is to be expected; the results of WC_Install::get_tables() are not sorted, so the order of the tables comes out jumbled:

1) WC_Tests_Install::test_get_tables
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
-    8 => 'wptests_woocommerce_orders'
-    9 => 'wptests_woocommerce_payment_tokenmeta'
-    10 => 'wptests_woocommerce_payment_tokens'
-    11 => 'wptests_woocommerce_sessions'
-    12 => 'wptests_woocommerce_shipping_zone_locations'
-    13 => 'wptests_woocommerce_shipping_zone_methods'
-    14 => 'wptests_woocommerce_shipping_zones'
-    15 => 'wptests_woocommerce_tax_rate_locations'
-    16 => 'wptests_woocommerce_tax_rates'
+    8 => 'wptests_woocommerce_payment_tokenmeta'
+    9 => 'wptests_woocommerce_payment_tokens'
+    10 => 'wptests_woocommerce_sessions'
+    11 => 'wptests_woocommerce_shipping_zone_locations'
+    12 => 'wptests_woocommerce_shipping_zone_methods'
+    13 => 'wptests_woocommerce_shipping_zones'
+    14 => 'wptests_woocommerce_tax_rate_locations'
+    15 => 'wptests_woocommerce_tax_rates'
+    16 => 'wptests_woocommerce_orders'

I'm working on fixing this within WooCommerce core in woocommerce/woocommerce#20045.

…ing several PRs from Liquid Web), we can now switch to using the master upstream for testing WooCommerce integration
… {dir-name}/woocommerce-custom-orders-table.php
…plugin isn't loaded until after WooCommerce itself
This commit ensures that the woocommerce_orders table is explicitly dropped at the start of each test (since we're testing that the table can be created). Additionally, some of the methods designed to aid in testing table creation/destruction have been moved from the base TestCase class into this single test case.
@bswatson bswatson merged commit ba5bba7 into develop May 14, 2018
@bswatson bswatson deleted the fix/test-refactoring branch May 14, 2018 19:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants