Commit Graph

1738 Commits

Author SHA1 Message Date
Christopher Allford b9ceabaa52 Utilized the constants package to fix the failing tests 2020-02-04 15:50:23 -08:00
Christopher Allford 1d15df860e Merge branch 'master' into fix/25438.2 2020-02-04 15:06:26 -08:00
Christopher Allford 57734ca8ce Merge branch 'master' into refactor/add-jetpack-constants 2020-02-04 14:36:35 -08:00
Rodrigo Primo fb3b977a16 Add test to make sure that negative fees never make order total negative
For some reason unknown to me, the following commit added logic to make
sure that negative fees never make the order total negative: 804feb9333

Probably by accident, commit 4326e39250 changed this logic when `$fees_total += $item->get_total()` was replaced by `$fees_total += $fee_total`:

4326e39250 (diff-9b4164165828b26c4b7aec01c7b17884R1594)

This commit adds a failing test that ensures that the old behavior is
tested. This test needs to be fixed before we merge the changes proposed
in PR #25504.
2020-02-04 15:33:21 -03:00
Rodrigo Primo 08e0936aa6 Improve coverage of WC_Abstract_Order::calculate_totals() test
This commits improves the coverage of the
WC_Abstract_Order::calculate_totals() test by including a fee to the
order used to test the method.
2020-02-04 15:26:52 -03:00
Rodrigo Primo b87d0e26fe Add basic unit test for WC_Abstract_Order::get_total_fees() 2020-02-04 15:13:27 -03:00
Claudio Sanches 94d1b742ad
Merge pull request #25545 from woocommerce/prep/after-3.9
Bumped versions for the upcoming release.
2020-02-04 13:05:27 -03:00
Peter Fabian 4a506ebcf7
Merge pull request #25530 from woocommerce/fix/country-region-label
Fix/country region label
2020-02-04 13:54:22 +01:00
Peter Fabian f57fef5bdd Updated unit tests. 2020-02-04 13:45:28 +01:00
Christopher Allford c5e1fc6c45 Merge remote-tracking branch 'origin/master' into refactor/add-jetpack-constants 2020-02-03 11:50:16 -08:00
Peter Fabian e613056634 This perhaps better represents the spirit of the test. 2020-02-01 14:19:22 +01:00
Christopher Allford 1d1413b4ee Replaced direct access of many constants with the Constants library 2020-01-31 22:18:47 -08:00
Peter Fabian 132ced6039 Fixed test for 4.0. 2020-01-31 21:05:50 +01:00
Peter Fabian 6410ef9156 Updated since tags for the upcoming version. 2020-01-31 18:03:54 +01:00
Claudio Sanches 052fbfcb8c Test WC_Email::style_inline() 2020-01-29 17:07:18 -03:00
Christopher Allford 6ad091a9b7 Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
Christopher Allford bb09a8a4ea Prevented the COD payment gateway's "enable_for_methods" option loading outside of correct use-cases
Note: The tests fail in this commit because of the defines. Ran individually there are no problems, but I'm going to make another PR to merge in a package to make testing constants possible, and then come back to fix this after it gets merged.
2020-01-28 14:33:53 -08:00
Claudio Sanches b3ea0b17b4 Merge branch 'master' into refactor/eu-vat-brexit 2020-01-27 13:15:54 -03:00
Rodrigo Primo 4e58f77575
Merge pull request #25322 from woocommerce/pr-25242
Prevent fatal error in set_current_gateway with no WC session
2020-01-17 09:54:03 -03:00
Rodrigo Primo 2668bf6025
Merge pull request #25314 from woocommerce/fix/24746
Removed the lowercase conversion of product search terms
2020-01-16 16:29:07 -03:00
Rodrigo Primo 8aad482bc1 Fix typo 2020-01-16 15:31:50 -03:00
Rodrigo Primo cb85c981ac Merge branch 'master' into pr-25242 2020-01-16 15:30:58 -03:00
Claudio Sanches bccb93fa3c
Merge pull request #25378 from woocommerce/fix/25361
Add license key support to MaxMind GeoLite2 database downloads
2020-01-15 20:51:14 -03:00
Rodrigo Primo 793dba81f1 Fix failing unit test
This commit fixes the unit test
WC_Tests_API_Functions::test_wc_rest_upload_image_from_url_should_return_error_when_invalid_image_is_passed() which was failing due to a change in a WordPress core message with the following error:

```
2) WC_Tests_API_Functions::test_wc_rest_upload_image_from_url_should_return_error_when_invalid_image_is_passed

Failed asserting that two strings are equal.

--- Expected

+++ Actual

@@ @@

-'Invalid image: File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.'

+'Invalid image: File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini file or by post_max_size being defined as smaller than upload_max_filesize in php.ini.'

/home/travis/build/woocommerce/woocommerce/tests/unit-tests/util/api-functions.php:89
```

(https://travis-ci.org/woocommerce/woocommerce/jobs/637353161#L402)

This test only fails when using WordPress nightly build (the yet to be
released WP 5.4).

To fix this problem, this commit adds an if statement to check for different error
messages depending on the WordPress version that is being used to run
the tests. In the future, we might want to refactor this test to remove
its dependency to a WordPress error message to make it more robust and
stable.
2020-01-15 11:17:49 -03:00
Claudio Sanches 992e13fb08 Updated implementation of geolite2 2020-01-14 16:24:07 -03:00
Christopher Allford 7a5083e47b Revert "Added a database option to allow for selecting different MaxMind databases"
This reverts commit d32c470cea.
2020-01-13 14:41:24 -08:00
Christopher Allford d32c470cea Added a database option to allow for selecting different MaxMind databases 2020-01-13 14:10:08 -08:00
Christopher Allford 6d3a3053c5 Moved the database file into the woocommerce_uploads folder 2020-01-13 08:53:43 -08:00
Christopher Allford 645affb7f3 Removed permanently failing unit test for deprecated GeoLite2 library integration 2020-01-13 08:17:11 -08:00
Christopher Allford 4f6aec61fd Added support for a randomized MaxMind database file prefix 2020-01-13 08:16:44 -08:00
vedanshujain f0f3b21a36 Added unit tests for setting current gateway 2020-01-13 14:18:59 +05:30
Claudio Sanches f253c87096 Fixed unit tests 2020-01-10 17:14:44 -03:00
Claudio Sanches 49aed6f6ca Remove alternatives for deprecated methods 2020-01-10 16:31:27 -03:00
Claudio Sanches 48547143f4 Fixed integration ID 2020-01-10 15:02:56 -03:00
Christopher Allford f5cbca5beb Added unit tests for the MaxMind integration class 2020-01-10 02:47:43 -08:00
Christopher Allford 19ded6609d Refactored the MaxMind database class to not use static methods in order to make testing the integration class easier 2020-01-10 02:09:51 -08:00
Christopher Allford bbbfc3bfab Moved the MaxMind geolocation lookup into the integration class 2020-01-09 23:46:25 -08:00
Christopher Allford f91ff82806 Moved the loading of the database class into the integration 2020-01-09 21:29:47 -08:00
Christopher Allford bf057927ae Moved the loading of integration classes into the WC_Autoloader 2020-01-09 15:46:01 -08:00
Christopher Allford 3e597e6f68 Replaced the Geolocation database fetching functionality with MaxMind integration 2020-01-09 00:31:51 -08:00
Christopher Allford f23c26a9f9 Fixed a permissions conflict caused by the dummy GeoLite2 archive's date
The test would fail if the web server had stored the data already!
2020-01-08 22:56:07 -08:00
Christopher Allford 95e59fc777 Made the database service class methods static for convenience \ 2020-01-08 21:59:04 -08:00
Christopher Allford 1eb49ef8b8 Added filterable support for fetching the database path
This replaces the corresponding geolocation class functionality. We are deprecating the woocommerce_geolocation_local_database_path filter in favor of the woocommerce_maxmind_geolocation_databse_path filter. Since we want the option to turn this into a feature plugin, it's wise to make sure nothing is too generic.
2020-01-08 21:48:05 -08:00
Christopher Allford 46d7f16b19 Added support for downloading and extracting the GeoLite2 database 2020-01-08 21:09:35 -08:00
Christopher Allford a477f9367d Added support for creating default integrations 2020-01-08 21:05:14 -08:00
Claudio Sanches 85a077b939 Coupon race condition prevention 2020-01-06 19:44:24 -03:00
Claudio Sanches 2ce4a60ff1
Remove old unit test 2020-01-06 19:37:47 -03:00
vedanshujain 42dd1bf32b Add an address so that shipping can be calculated 2019-12-26 14:04:52 +05:30
vedanshujain 31726d1a37 Update version numbers 2019-12-26 13:55:43 +05:30
Christopher Allford ac22406763 Fixed the unit tests broken by the requirement that a valid address must be set to calculate shipping rates 2019-12-26 13:55:43 +05:30
Christopher Allford c54fa91145 Added unit tests for checking whether a package is shippable or not 2019-12-26 13:55:41 +05:30
Christopher Allford e800b40ad6 Made packages with incomplete destinations unshippable 2019-12-26 13:55:41 +05:30
Christopher Allford 874be93c14 Removed the lowercase conversion of product search terms
When searched in a case sensitive manner, the conversion to lowercase causes uppercase matches that would have been found to be lost. This change increases the tolerance of the OR search format while also removing this unintended side-effect.
2019-12-24 15:00:40 -08:00
Rodrigo Primo 487f96d844 Fix WordPress.DateTime.CurrentTimeTimestamp vilations
This commit fixes all violations of the WordPress.DateTime.CurrentTimeTimestamp sniff automatically using phpcbf.
2019-12-20 14:23:05 -03:00
Rodrigo Primo 62d6b05b58 Fix Generic.Formatting.MultipleStatementAlignment violations
This commit fixes all violations of the Generic.Formatting.MultipleStatementAlignment sniff automatically using phpcbf.
2019-12-20 14:21:08 -03:00
vedanshujain ff2a8a58f2 Commented out flaky test 2019-12-17 19:13:19 +05:30
vedanshujain 9b7343d23b Applied coding standards 2019-12-17 19:13:19 +05:30
vedanshujain 53bfcea110 Use same filter for stocks and coupon for consistency. 2019-12-17 19:13:19 +05:30
vedanshujain 72545c44b7 Add support for `_held_for_checkout` records to improve performance.
This will also improve transactional stability and avoid race conditions by providing a way to lock usage counts.
2019-12-17 19:13:19 +05:30
Claudio Sanches 2975b3a7b7 Rate limit feature 2019-12-11 01:38:19 -03:00
Claudio Sanches f7632de06e
Merge pull request #25164 from om4james/webhook-delete-cache
Delete cached webhook data when a webhook is deleted
2019-12-10 22:45:42 -03:00
Claudio Sanches 523c72f265 Fix WordPress nightly unit tests (#25198)
* Remove images after uploaded in WC_Tests_Product_Data

* Remove attachment after test

* Fixed image_id
2019-12-10 13:57:52 -03:00
Claudio Sanches 104f40c36e
Merge pull request #24281 from woocommerce/fix/24269
Handle multiple decimal points
2019-12-09 14:07:29 -03:00
Francesco Leanza 59af851069
Merge branch 'master' into fix/25091 2019-12-09 16:46:02 +01:00
Andrej Mernik d20d429e32 Add postcode validation for Slovenia (#25174)
Add postcode validation for Slovenia
2019-12-09 10:09:45 -03:00
Claudio Sanches b4af5f3c89 Updated regex to allow only one decimal point 2019-12-06 11:11:47 -03:00
Claudio Sanches e535a16b48 Fixed unit tests 2019-12-06 11:00:40 -03:00
James Collins 596ac29ba4 phpcs fixes 2019-12-06 10:34:59 +08:00
James Collins 7c5d06c309 Unit test to demonstrate the problem of duplicate webhook deliveries occurring 2019-12-06 09:41:33 +08:00
James Collins 0246b02a94 Merge branch 'master' into webhook-delete-cache 2019-12-06 08:57:54 +08:00
Claudio Sanches 8dbf7edb6f Fixed unit tests 2019-12-05 21:26:03 -03:00
Rodrigo Primo 27915dd696 Exception when WC_Product_Variation is instantiated with the wrong type
This commits changes WC_Product_Variation to raise an exception when the
class is instantiated with an ID that belongs to a post object that is
not a product variation.

This is necessary to avoid problems like the one described in #24956
where passing a variable product ID to WC_Product_Variation would result
in transparently modifying the variable product title and excerpt.
2019-12-05 15:45:48 -03:00
Claudio Sanches d7e2a98aaf
Merge pull request #24828 from woocommerce/fix/24695
Adds shared code between Orders and Cart calculation logic.
2019-12-05 12:39:50 -03:00
Peter Fabian 4dfa68b62d More PHPCS fixes. 2019-12-05 15:46:13 +01:00
Peter Fabian 9b398947dd Fixed the test by sleeping longer. 2019-12-05 15:17:34 +01:00
Peter Fabian 3ba3d5cf1b Made the fail messages unique. 2019-12-05 15:07:03 +01:00
Peter Fabian 7bfbe7a5f1 Removed incorrect comment. 2019-12-05 15:05:38 +01:00
Peter Fabian 0d3074a554 Added rate limiting to Add payment method. 2019-12-05 12:03:02 +01:00
Rodrigo Primo 3af024fc5c
Merge pull request #25031 from woocommerce/feature/24956
Introduced wc_get_product_object() helper
2019-12-04 16:53:04 -03:00
Claudio Sanches e3b2d9f10c Merge branch 'master' into feature/inline-notices 2019-12-04 16:26:10 -03:00
Claudio Sanches 5fdb880831
Merge branch 'master' into feature/24956 2019-12-04 16:18:39 -03:00
Claudio Sanches 8033d5751e Changed wc_get_product_classname function name to wc_get_product_object 2019-12-04 16:15:16 -03:00
Claudio Sanches a12c25862b
Revert "Add support for '_held_for_checkout` records to prevent race conditions." 2019-12-04 16:03:05 -03:00
Claudio Sanches 0686e6f1cd
Merge pull request #25000 from woocommerce/feature/pay-button-support
Initial support for "pay button"
2019-12-04 16:02:02 -03:00
Rodrigo Primo 4af9a94129 PHPCS fixes 2019-12-04 15:52:20 -03:00
Claudio Sanches adbb4fd2d3
Merge pull request #24937 from jenkoian/wc-placeholder-attrs
Add support for custom attributes to wc_placeholder_img().
2019-12-04 15:42:41 -03:00
James Collins 7187db66e1 Add unit test 2019-12-04 12:29:40 +08:00
Claudio Sanches 0c486785ad
Merge pull request #25089 from woocommerce/fix/24009
Add support for '_held_for_checkout` records to prevent race conditions.
2019-12-03 17:47:22 -03:00
Claudio Sanches df4eb9c817 Use wc_get_order() in unit tests, and fixed coding standards 2019-12-03 16:44:37 -03:00
Claudio Sanches 988b72e461 Updated filter name to woocommerce_hold_stock_for_checkout
Also fixed coding standards
2019-12-03 16:38:17 -03:00
Rodrigo Primo 567b667acf Improve wc_print_notices() test coverage 2019-12-03 15:29:10 -03:00
Claudio Sanches 6a395e2485
Merge pull request #25064 from woocommerce/fix/24315
Optimize variable product duplication slug generation
2019-12-03 15:28:55 -03:00
vedanshujain 8c2c83d488 Use `wc_round_tax_total` to make it consistent with how we round taxes.
When price includes taxes, we round down. This patch uses the correct method to round taxes depending on the mode instead of plain rounding.
2019-11-27 03:13:39 +05:30
vedanshujain 5ef41f1ecc Empty cart before test to make sure everything in cart exists 2019-11-26 18:21:24 +05:30
vedanshujain 60cd7b3651 Refactor Order Class to use shared calculation logic.
We added a trait to move shared logic betweem Orders and Cart. This commit refactors Order class to use that shared logic.
Also adds a test for a failing case.
2019-11-25 17:53:14 +05:30
Rodrigo Primo 6cd08dc7bd Use the spread operator instead of call_user_func_array() in WC_Data_Store
This commit replaces a call to call_user_func_array() in WC_Data_Store::__call() with argument unpacking using the spread operator which was introduced in PHP 5.6. This change should improve WooCommerce performance a tiny bit since WC_Data_Store::__call() is called somewhat frequently and call_user_func_array() has a bad performance reputation. I added one unit test to make sure this change doesn't break the functionality of the altered method.
2019-11-21 11:52:47 -03:00
Rodrigo Primo ed1c4b11b8 Fix PHPCS errors in WC_Tests_Data_Store class file 2019-11-21 10:41:27 -03:00
Rodrigo Primo 44b09cb15a Remove unused test method 2019-11-21 10:40:38 -03:00
vedanshujain 70a54d0639 Added Unit Tests for `held_for_checkout` records. 2019-11-21 18:11:37 +05:30
Francesco Leanza dd3427958b Fixed order totals calculation if it contains taxable and non-taxable products and percentage coupons
Added PHPUnit tests
2019-11-21 11:28:22 +01:00