Commit Graph

249 Commits

Author SHA1 Message Date
Nestor Soriano 2b8cac7cf2 Fix the REST API entry point to add coupons to an order.
- Check input (no 'id', has 'code') and throw an error if needed
  before removing the existing coupons, so an invalid input
  won't cause the loss of these existing coupons.
- Also, check that the coupon is actually valid as part of the
  input check.
- Cache the coupon objects that are created during the input check,
  and apply them directly.
- Don't check if 'coupon_lines' is an array and contains arrays,
  that's already done by the REST API engine by looking at the schema.
- Adjust unit tests.
2021-03-24 15:19:34 +01:00
Peter Fabian 1b53b724b2 Fix existing tests. 2021-03-11 17:02:22 +01:00
Saggre 24167a5eed Fix typos in docs 2021-03-05 11:19:58 +02:00
louwie17 893fe6cc24
Merge pull request #29149 from woocommerce/update/28569_status_widget_net_sales_link
Woocommerce dashboard status widget net sales link and logic
2021-02-25 09:09:29 -04:00
Peter Fabian 35d4ee4073
Merge pull request #28699 from woocommerce/fix/absolute-download-paths
Prevent local relative downloadable products to be treated as "absolute"
2021-02-23 11:50:34 +01:00
Lourens Schep 966aca59ad Removed external class and moved logic to private functions 2021-02-18 16:05:00 -04:00
Lourens Schep 0fc81a27fc Add tests 2021-02-18 12:01:52 -04:00
Claudio Sanches 6fae8ca40b
Merge pull request #29146 from woocommerce/fix/27290-rest-api-order-updates
Throw an error if a coupon item ID (readonly) is specified during an order update | #27290
2021-02-16 17:04:49 -03:00
barryhughes f79b3f9120 Supporting tests for handling coupon-related order updates (via REST API) | #27290 2021-02-16 10:28:46 -08:00
artpi cca06857e9 Fix tests 2021-02-16 16:19:55 +01:00
artpi dc7410b6b3 Extra protections 2021-02-16 15:51:49 +01:00
artpi 774d7e38cd Better url parsing 2021-02-16 15:09:23 +01:00
artpi 3ffeeea8e4 Add a few tests 2021-02-16 10:52:34 +01:00
Claudio Sanches 74bb66dc6d
Merge pull request #27671 from mahmoudsaeed/master
Make WC_Tax::get_tax_rate_classes() public
2021-02-15 14:31:25 -03:00
Vedanshu Jain 5a707f3e74
Merge pull request #28849 from woocommerce/fix/27521-2
Verify country code on checkout
2021-02-11 18:59:04 +05:30
Nestor Soriano 07f3d9dee6 Add unit tests for the WC_Checkout class. 2021-02-08 15:49:38 +01:00
Nestor Soriano 2c957d2531 Merge branch 'master' into fix/25900-take-2 2021-01-29 10:00:51 +01:00
Claudio Sanches ea54d5ad5f
Merge pull request #28679 from woocommerce/fix/woocommerce-gutenberg-products-block-issues-3565
Show correct WooCommerce pages status if they are using blocks vs shortcode.
2021-01-18 19:26:34 -03:00
budzanowski a283433f4d Add block utils unit tests. 2021-01-12 14:41:55 +01:00
Nestor Soriano f4a1f12824 Fix code sniffer errors 2021-01-05 17:23:23 +01:00
Nestor Soriano f284ae8af3 Fix end of line handling for PHP 8 in WC_Tests_Log_Handler_Email
In PHP 7 the mail function generates PHP-style end of lines (\n),
and that's what these unit tests were assuming; in PHP 8 however
the proper network-style end of lines (\r\n) are generated.
This commit fixes the tests to be compatible with both styles.
2021-01-05 16:04:30 +01:00
vedanshujain 9ca52ee73b Fix unit test to use new coupon error messages.
This also removes some cart operations which are not needed anymore to since cart already has items that we were adding in those tests.
2020-12-16 16:21:33 +05:30
Christopher Allford 30d2e278b9 Replaced the deprecated `WC_Admin_Note` class 2020-11-12 13:26:30 -08:00
vedanshujain 62ae94d93e Add shipping, tax and fee lines to refund response for better information. 2020-11-11 18:47:48 +05:30
Nestor Soriano d620f1d232 Fix #25900 - image size customisation controls not shown
- Added the `ThemeSupport class`, with methods to add and get
  theme support options.
  - It also has a new `add_default_options` method that adds the
    options under a `_defaults` key.
- The `WC_Twenty_*` classes now use `ThemeSupport` instead of
  the `add_theme_support` function to define image and thumbnail sizes.
  - The values are defined as default options.
- The `WC_Shop_Customizer` class now uses `ThemeSupport` instead of
  `wc_get_theme_support` to check if image and thumbnail sizes UI
  should be rendered.
  - The check is made excluding default values.

With these changes the UI to change the image and thumbnail sizes
is hidden only if the options are added as non-defaults elsewhere.

Additional changes:

- The code of the `wc_get_theme_support` function is replaced with
  a simple call to `get_option` in `ThemeSupport`.
- Added the utility class `ArrayUtil`.
2020-11-04 13:01:53 +01:00
Shiki 30854efc1b Replace assertStringContainsString with strpos
This is to make the PHP 7.0 CI pass.
2020-10-26 13:28:04 -03:00
Shiki ba3e107cb8 Orders V2 API: Add test for parent_name 2020-10-26 13:28:04 -03:00
Shiki 94ecfcab34 Orders API: Add parent_name to schema 2020-10-26 13:28:04 -03:00
Shiki c6f82b96a1 Orders API: Add unit test for parent_name line_item property 2020-10-26 13:28:04 -03:00
Shiki a05316878e Orders API Tests: Fix failing tests because of the new property 2020-10-26 13:28:04 -03:00
Shiki 3a1b125e3a Fix coding style 2020-10-26 13:28:04 -03:00
Mahmoud Saeed ad0eff11de Add unit test for WC_Tax::get_tax_rate_classes() 2020-10-15 07:34:20 +02:00
vedanshujain a332b399d3 Use variable instead of magic constants. 2020-10-14 18:50:44 +05:30
vedanshujain c01f32a390 Use default value if formatted value is not available 2020-10-14 14:51:19 +05:30
vedanshujain 8e12de5d3c Merge branch 'fix/api/229-unit-test' of https://github.com/shiki/woocommerce into fix/api/229 2020-10-14 13:53:03 +05:30
Shiki 1be78d1ebf Use different terms to avoid clash with the similar V2 test
I suppose I could have deleted the attribute and term first but I think
this is better and shorter. Maybe.
2020-10-13 22:32:32 +05:30
Shiki a9bf6b71ac OrdersV2: Add test for line items meta_data
This currently fails because it's not implemented yet.
2020-10-13 22:32:32 +05:30
Shiki 871a9e0b8f Add line items meta_data schema test for Orders V2 and V3
This currently fails because the expected meta_data properties are only
available in V3.
2020-10-13 22:32:32 +05:30
Shiki c5fd3ed21c WC_Tests_API_Orders: Add test data for site-level attributes 2020-10-13 22:32:31 +05:30
Shiki 62f1705690 WC_Tests_API_Orders: Rearrange order variable for clarity 2020-10-13 22:32:31 +05:30
Shiki c16ec9bf54 WC_Tests_API_Orders: Rename first_meta_data to size_* 2020-10-13 22:32:31 +05:30
Shiki a0d9b49e43 Add unit test for an Order's line item meta data. 2020-10-13 22:32:31 +05:30
Néstor Soriano c15488d840
Merge pull request #27830 from woocommerce/php8/fix-round-function-with-non-numeric-argument 2020-10-09 08:01:44 +02:00
Néstor Soriano e4b78cedbf
Merge pull request #27748 from woocommerce/remove-leftovers-from-improved-filtering-by-attribute-for-variations
Remove leftovers from the reverted improved filtering mechanism for variations
2020-10-08 15:45:09 +02:00
Néstor Soriano ab529835fa
Merge pull request #27840 from woocommerce/php8/fix-required-parameters-after-optional
[PHP 8] Convert optional-before-required parameters into required parameters
2020-10-08 14:22:52 +02:00
Nestor Soriano b71f876cba Reintroduce the dependency injection related code.
After the League's Container package has been reintroduced, all the
code that implements the dependency injection mechanism in woocommerce
can be brought back as well.
2020-10-08 09:28:05 +02:00
Nestor Soriano ed33a607a7 Remove a useless test assertion that fails in PHP 8
The assertion is useless (the constant is already tested a few Lines
above), and it was failing in PHP 8 because 'auto' < 2 is evaluated
as false, while it's evaluated to true in PHP 7.
2020-10-02 15:27:26 +02:00
Nestor Soriano 7485b9165f Convert optional-before-required arguments to required.
In PHP 8 required parameters after optional parameters in
function/method signatures trigger a deprecation notice. These type
of parameters are pointless since a value needs to always be
provided for them anyway, so they are actually de-facto required.

This commit converts all these not-so-optional parameters into
truly required parameters by removing their default values.
2020-10-02 09:45:09 +02:00
Nestor Soriano 52eed70f04 Add a 'NumberUtil' class with a 'round' method.
There's a number of places in the WooCommerce codebase where the
built-in function 'round' is executed passing a non-numeric value
(not a number and not a string that can be parsed as a number),
for example round(''). In PHP 7 this yields a value of 0, but in
PHP 8 this throws an error.

This commit adds a 'NumberUtil' class with a static 'round' method,
this method checks if the passed value is numeric and if so it just
executes the built-in function, otherwise it returns 0. And all the
calls to 'round' in the codebase are replaced with 'NumberUtil::round'.
2020-10-01 11:08:51 +02:00
Nestor Soriano b1e81d02da Fix code style/sniffer errors in a few files. 2020-10-01 11:08:51 +02:00
Nestor Soriano a94ea7f51f Remove logic for storage of attribute terms for variations
A mechanism for improved filtering by attribute for variations was
introduced some time ago. This mechanism implied maintaining term
relationships for variations, where the terms were the attributes
that defined the variation.

The mechanism was reverted because it was complex and presented many
issues, but the code that created those term relationships was kept.
This pull request removes that code and the associated unit tests.
2020-09-22 16:31:06 +02:00
Ron Rennick 9915a5b142 merge master 2020-09-18 12:53:28 -03:00
Claudio Sanches 29b8b0d60d
Merge pull request #27701 from woocommerce/fix/rest-api-package-tag
Fixed usage of package tag in REST API and templates
2020-09-17 18:45:14 -03:00
Claudio Sanches 7fae819928 Fixed package tag 2020-09-17 14:34:36 -03:00
Claudio Sanches 3377c60c5e
Merge pull request #27433 from woocommerce/fix/remove-relative-include-paths
Change relative include paths to absolute include paths
2020-09-17 13:15:40 -03:00
Claudio Sanches 70c7adfeb7 Fixed usage of package tag in REST API and templates 2020-09-17 11:56:08 -03:00
jonathansadowski 2bcdbacc98
Merge pull request #27625 from woocommerce/revert-improved-filtering-for-variations
Revert improved filtering for variations
2020-09-10 12:42:15 -05:00
Christopher Allford ae697f9fe2 Prevented zero from being considered empty when validating posted variation attributes 2020-09-09 11:29:31 -07:00
Nestor Soriano 70a1cb2f1f Revert improved filtering for variations.
This commit reverts the functionality introduced in PR #26260
(later refined by #27175, #27190, #27508) in which filtering by
attribute using the layered nav widget was improved to handle the
cases of variations out of stock. The revert is a response to the
numerous problems reported by users in Woo 4.4 and 4.5

Not all the code has been reverted, only the code that resulted in
visible functionality changes. Thus, the code that generates
term relationships for variations is still in place to keep database
consistency and to keep the reverting changes to the minimum needed.
2020-09-09 17:36:26 +02:00
Shiki d6600d8338 Version3/orders.php: Re-add assertion for `meta_data` 2020-09-01 14:29:38 -06:00
Shiki 5651befdd9 Version3/orders.php: Remove assertion for `meta_data`
The new meta_data output will include keys like `display_key` and
`display_value`. The assertion will be re-added in a later commit.
2020-09-01 14:22:38 -06:00
Shiki 64bd1e0fd5 Fix formatting errors in orders.php 2020-09-01 14:21:14 -06:00
Ron Rennick 8fe3bcb90e rebase to current master 2020-08-28 10:59:43 -03:00
Claudio Sanches 085b4b53fa
Merge pull request #27487 from woocommerce/update/choice-of-words
Improve choice of words
2020-08-27 19:30:54 -03:00
Claudio Sanches c4ccc38780 Fixed use __DIR__ for relative paths 2020-08-26 18:46:44 -03:00
Shiki ecb2936f9e Use different terms to avoid clash with the similar V2 test
I suppose I could have deleted the attribute and term first but I think
this is better and shorter. Maybe.
2020-08-26 23:51:36 +05:30
Shiki face3fe27e OrdersV2: Add test for line items meta_data
This currently fails because it's not implemented yet.
2020-08-26 23:51:36 +05:30
Shiki ad00eb3a98 Add line items meta_data schema test for Orders V2 and V3
This currently fails because the expected meta_data properties are only
available in V3.
2020-08-26 23:51:36 +05:30
Shiki 2a01aa968f WC_Tests_API_Orders: Add test data for site-level attributes 2020-08-26 23:51:36 +05:30
Shiki dc2a4d1ccc WC_Tests_API_Orders: Rearrange order variable for clarity 2020-08-26 23:51:36 +05:30
Shiki 00a5c3101e WC_Tests_API_Orders: Rename first_meta_data to size_* 2020-08-26 23:51:36 +05:30
Shiki d681a8c7a4 Add unit test for an Order's line item meta data. 2020-08-26 23:51:36 +05:30
Claudio Sanches 5240682f38 Improve choice of words 2020-08-25 18:03:03 -03:00
Claudio Sanches a133e56ebd Fixed unit tests 2020-08-25 16:13:49 -03:00
Ron Rennick 81dae70033 phpcs fixes 2020-08-25 15:41:31 -03:00
Ron Rennick de79f1a3cd update unit tests for included Paypal gate name change 2020-08-25 15:36:50 -03:00
Ron Rennick 51afe3207a
Merge pull request #27023 from HikeMike/add/hidden-form-field
"Hidden" field type added to woocommerce_form_field() #26468
2020-08-20 11:48:26 -03:00
Christopher Allford 358db5dc3e Removed the internals of the Container pending package conflict resolution
Since reverting the PR at this point would be a mess I've gone ahead and removed the internals of the container. We should aim to keep the class since it's now part of our public API but it won't work as expected anymore. This is fine for now since we don't actually have anything in it!
2020-08-18 20:39:48 -07:00
Claudio Sanches e102ec3d83 Merge branch 'master' into fix/25133 2020-08-17 14:59:49 -03:00
Claudio Sanches bb0c4406de
Merge pull request #27314 from woocommerce/add/unit-tests-27108
Added unit tests for #27244
2020-08-14 15:32:02 -03:00
Ron Rennick 45391c4b18 update unit test for account page being automatically created 2020-08-14 10:36:16 -03:00
Ron Rennick f0ad8a01be merge current master 2020-08-13 14:33:07 -03:00
vedanshujain 7fa6510c1a Add a explicit test for null as well 2020-08-13 16:52:16 +05:30
vedanshujain dd9b9cfae2 Add test for update in date-time field 2020-08-13 16:32:00 +05:30
vedanshujain 4294e06f7a Add test for variation v2 controller for complex meta object 2020-08-13 15:46:31 +05:30
vedanshujain 9f680aa120 Add test for null meta value as well 2020-08-13 14:17:28 +05:30
vedanshujain 826fdde721 Add unit tests for checking that updating complex meta is possible 2020-08-13 13:27:00 +05:30
Claudio Sanches 1839feae91 Added unit tests for #27244 2020-08-12 18:50:25 -03:00
Ron Rennick 0b0595ab4c
Merge pull request #27048 from vallter2/postcode-bih
Add postcode validation for Bosnia and Herzegovina
2020-08-10 16:24:06 -03:00
Claudio Sanches 02cf0dfaed
Merge pull request #27239 from woocommerce/fix/package-tag
Fix usage of "package" tag in file headers
2020-08-07 13:37:24 -03:00
Claudio Sanches 17f9883f00 Changed | to \ 2020-08-07 13:36:41 -03:00
Claudio Sanches 48732ee0dd Fixed package tag 2020-08-07 13:35:15 -03:00
Néstor Soriano 76cf1e4e93
Merge pull request #27140 from woocommerce/fix/23790
Always sanitize coupon code to prevent inconsistent between admins and shop owners
2020-08-07 12:42:02 +02:00
Néstor Soriano a13a0d2187
Merge pull request #27179 from woocommerce/fix/26741
Release coupon holds when status it updated to cancelled regardless of recorded coupons
2020-08-07 11:27:45 +02:00
vedanshujain 2f76e52fa7 Skip test for < 5.3 as feature is not supported. 2020-08-06 14:34:02 +05:30
vedanshujain 55a9687e6d Make api included structure more linear. 2020-08-06 14:34:02 +05:30
vedanshujain cfe357cfb2 Fix UT to add predefined values to run tests in isolation. 2020-08-06 14:34:02 +05:30
Claudio Sanches d48f1d4e2e Fixed package tag usage 2020-08-05 13:36:24 -03:00
vedanshujain 1ada7d8b26 Merge branch 'master' of https://github.com/woocommerce/woocommerce 2020-08-04 18:22:41 +05:30
Nestor Soriano 71fccd6a07 Fix: pagination controls not displaying in products list.
This bug was introduced in #26260. The sequence is:

1. WC_Query::adjust_posts_count runs, to handle found_posts filter,
   this indirectly executes wc_setup_loop.
2. At this point $GLOBALS['wp_query']->max_num_pages hasn't been set
   yet, and has a value of 0. Thus the loop variable total_pages
   is set to 0.
3. Later wc_setup_loop runs again and this time
   $GLOBALS['wp_query']->max_num_pages is already set, but since
   the loop variable total_pages already exists, it keeps its
   value of 0.
4. The pagination controls never show if total_pages is less than 2.

The fix consists of hooking into the_posts to set the value of
total_pages again, at that point $GLOBALS['wp_query']->max_num_pages
is already set.
2020-07-31 16:40:25 +02:00