This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…h of varchar columns in the custom table
Globally, the longest postal codes appear to be ~12 characters long, but 20 gives us a bit of head room. Reference: - https://stackoverflow.com/q/325041/329911 - https://en.wikipedia.org/wiki/List_of_postal_codes - https://en.wikipedia.org/wiki/Postal_code
WooCommerce uses the ISO 3166-1 alpha-2 standard for countries, which dictates exactly two characters. Depends on woocommerce/woocommerce#20222 for all tests to pass.
FWIW, woocommerce/woocommerce#20222 has been merged but not backported to previous releases, so the |
…th WP_HTTP_TestCase::init()
…th WP_HTTP_TestCase::init()
Previous versions of WooCommerce had this in api/system-status.php, but this file was moved into the v2 subdirectory in woocommerce/woocommerce:246672818
Based on woocommerce/woocommerce:0e785d46, the HTTP request required by `WC_Tests_Product_CSV_Importer::test_import()` was failing for earlier versions of PHP (< 7.2), and thus causing a false positive when testing WooCommerce < 3.4.
There are situations where the Custom Orders Table plugin has had to ignore certain WooCommerce tests (for instance, if they're explicitly checking post meta), and those files are excluded in phpunit.xml.dist. Unfortunately, PHPUnit doesn't let you ignore a specific test method (e.g. `WC_Tests_REST_System_Status::test_execute_system_tool_add_order_indexes()`), but rather the whole file. In some cases, omitting the whole would be counter-productive, which is the case here: `WC_Tests_Order_Functions::test_wc_get_order_address_params()` will fail with the custom orders table, as the columns for `billing_country` and `shipping_country` are both `char(2)` (per WooCommerce's specification, countries should be stored using the ISO 3166-1 alpha-2 standard, e.g. "US" instead of "USA"), but earlier versions of the test suite hard-coded "USA". These tests were fixed in woocommerce/woocommerce#20222, but the patch has not been backported to earlier releases. Rather than changing the custom orders table schema to a suboptimal column-type for the sake of getting old tests to pass, this commit uses the `WC_VERSION` constant to conditionally add filters to modify *test* data within the WooCommerce core test suite on older versions. With this code in place, tests in (for example, WooCommerce 3.4, which doesn't include the patch from woocommerce/woocommerce#20222) will be setting a `billing_country` of "US" rather than "USA". For newer, post-patch releases, these filters will not be active.
bswatson
approved these changes
Sep 12, 2018
stevegrunwell
changed the title
WIP: Database table optimizations
Database table optimizations
Sep 12, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to optimize the custom orders table that is the plugin's namesake. @raunak-gupta provided some great notes in #48, so this PR is for working through them.
Fixes #48. Blocked by #64, #72, woocommerce/woocommerce#20222.