There were two outdated lists of WC tables. One used to drop tables when WC is uninstalled and another one to drop tables when a site is deleted in a multi site environment. This commit creates a new unified list of WC tables, adds the missing tables to this list and introduces a unit test that will fail if the list gets outdated.
WC doesn't support downgrades but the if condition that decides whether or not to call WC_Install::install() and apply database schema changes was checking if the WC version stored in the database is equal to the WC version in the code. This commit changes the check performed inside the if condition to verify if the WC version stored in the database is smaller than the version in the code. This way `dbDelta()` won't be called automatically by WC and revert database schema changes. This is particulary important for clustered providers where the version of the WC code running in one of the containers could be outdated and trigger a database downgrade.
To test the method WC_Install::check_version() it is not necessary to update the of the option 'woocoommerce_db_version' as this method uses only 'woocommerce_version'.
Removed the print_r() call as phpcs was complaining about it and there is no need to output the version values as phpunit will do that if the test fails.
This commit adds a new line to the section "WordPress environment" of the system status page to indicate whether or not WP external object cache is enabled.
This commit fixes a bug in WC_Customer_Download_Data_Store::get_downloads() that made impossible to change the order in which the query returned the results. This method accepts the arguments `order_by` and `order` but it was ignoring them and always using the default values ('permission_id' and 'ASC' respectively).
One of the assertions of the WC_Customer_Download_Data_Store::get_downloads() test method was modified to make sure the code now works.
This bug was introduced by commit a443419.
This commit simplifies WC_Customer_Download() tests by using hardcoded values for customer ID and e-mail instead of touching the database and creating a real customer for each test.
This commit improves WC_Customer_Download_Data_Store::get_downloads() performance by changing the way the SQL query is built. Before this change, this method would get all table fields even when just the permission_id field is returned. Now the method will get from the database only the fields that will be returned. The fields retrieved from the database can be controlled using the parameter `$args['return']`:
- 'objects' (default): all fields are retrieved from the database and an array of WC_Customer_Download objects is returned.
- 'ids': gets and return only permision_ids
- comma separated list of fields (new option added by this commit): gets and return only the required fields. Examples: 'user_email,download_id,order_id' or 'order_id,download_count'.
The wp_get_theme() function returns a WP_Theme object, which uses uppercase property names, which goes against typical WordPress conventions.
This uses the more modern (read: PHP_CodeSniffer 3.2.0+) syntax for temporarily disabling sniffs. For more details, please see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file.
The wp_get_theme() function returns a WP_Theme object, which uses uppercase property names, which goes against typical WordPress conventions.
This uses the more modern (read: PHP_CodeSniffer 3.2.0+) syntax for temporarily disabling sniffs. For more details, please see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file.
There are a number of files that are only loaded when another function is called (for example, load a reporting class when displaying a widget). An autoloader would be the ideal way to handle this (both in production and for tests), but until PHP compatibility is sorted out this commit adds an easy fix:
Testcases can now populate the protected, static $includes property with filepaths relative to the project root; when the testcase boots up, these files will automatically be included.
* Pass through additional args to wc_create_order in test
* Pass extra args to wc_create_order to improve coverage, test WP_Error check of wc_create_order
* wc_get_template_part test
* wc_enqueue_js test
* wc_get_log_file_name test
* wc_get_page_children test
* hash_equals test
* wc_rand_hash test
* wc_transaction_query test
* Fix script test and phpcs stuff
* Fix widget tests
* Move tests to correct file and fix phpcs
This commit renames PHPCS configutarion file to `phpcs.xml`. With the default name, it is not necessary to use the argument `--standard=phpcs.ruleset.xml` anymore when calling `phpcs`.
* Test for main WooCommerce class
* Check all class instances created from main class.
* Test all constants
* Test for deprecated hook handler classes as well
* Test template path constant
* Check static class instances
* get_cart_item_quantities test
* get_cart_item_quantities & get_cart_contents_weight tests
* check_cart_items test
* Check_cart_item_stock test
* Cart get_cross_sells test
* Cart get_tax_totals test
* WC_Customer_Download_Data_Store tests
This commit adds the exception message thrown when WC_Order::set_billing_email() is called with an invalid message to a test to fix it.
I couldn't find what change in WC codebase broke the test and I'm not sure why it is failing only when running using PHP 5.6:
https://travis-ci.org/woocommerce/woocommerce/jobs/315750242#L600