Commit Graph

148 Commits

Author SHA1 Message Date
Jeff Stieler 7a68bc5ff7
Ensure that API key descriptions are truncated over the REST API. 2021-10-19 12:33:19 +02:00
Paul Sealock ef015f740f git mv a few folders 2021-10-19 10:35:45 +13:00
Jeff Stieler 30e1067864 Add test coverage. 2021-10-05 12:21:38 -04:00
roykho bce05c811a
Revert "Tweak download filepaths"
This reverts commit 90e187b899.
2021-09-23 18:51:41 -07:00
Vedanshu Jain 5cdf979961
Merge pull request #30692 from woocommerce/fix/30231
Use proper location for taxes when adding products via admin
2021-09-22 15:14:13 +05:30
roykho 90e187b899
Tweak download filepaths 2021-09-21 12:36:52 -07:00
Nestor Soriano d254f2703c
Add a unit test for WC_Abstract_Order->add_product
The test verifies that if an order is passed in arguments, that order
is passed in turn to wc_get_price_excluding_tax.
2021-09-21 16:40:36 +02:00
Nestor Soriano 98a2391747
Add unit test for 'wc_get_price_excluding_tax'.
The test verifies that when an order is passed as an argument,
the order customer is passed to 'WC_Tax::get_rates'.
2021-09-13 10:16:18 +02:00
Nestor Soriano e1f19e2d23
Fix: 'woocommerce_email_settings' filter being triggered twice. 2021-08-02 09:33:18 +02:00
barryhughes fbda9cb58e Update with latest changes from trunk. 2021-07-21 14:54:53 -07:00
Joel Thiessen 9801cd80c6 Patcing tests relevant to new payment gateway API 2021-07-21 12:06:41 -07:00
barryhughes 46f9644eae Update test for product download settings. 2021-07-20 11:18:22 -07:00
Claudio Sanches 94bdcd0320
Merge pull request #27684 from woocommerce/refactor/settings-pages-classes-take-2
Refactor the settings pages, and add unit tests for them
2021-06-01 13:19:49 -03:00
Christopher Allford 070954c888 Revert #28187
The default functionality within the `ThemeSupport` class has an unintended
side-effect of breaking the existing default functionality within the
`wc_get_theme_support()` function. Since the default set in the support
class is prioritized over the one given to `ThemeSupport::get_option()`,
the WordPress options set in the Customizer are never used for images.
2021-05-21 12:10:15 -07:00
Vedanshu Jain 6667233eb1
Merge pull request #29762 from woocommerce/fix/29502
Update restock logic during refunds closes #29502
2021-05-21 22:53:22 +05:30
Nestor Soriano 22b5ec121f
Fix: no output for settings classes that directly override get_settings. 2021-05-13 09:24:25 +02:00
roykho b808d9a24f
Fix merge conflicts 2021-05-11 08:53:03 -07:00
roykho 8c3e90b3ce
Initialize _restock_refunded_items meta on order update 2021-05-11 08:35:48 -07:00
Nestor Soriano 8b12fee96f
Merge branch 'trunk' into refactor/settings-pages-classes-take-2 2021-05-07 12:16:13 +02:00
vedanshujain f53e9dde44 Use edit context to get unformatted price. 2021-05-07 14:59:14 +05:30
vedanshujain 6c2f30132d Add clear cart call to prevent side effects from tests. 2021-05-07 14:30:45 +05:30
vedanshujain 162588c42d Add test for when product prices has more precision than is displayed. 2021-05-07 14:30:44 +05:30
vedanshujain c834dfb98b Add test for when entered price has more precision than displayed price. 2021-05-07 14:30:44 +05:30
vedanshujain 2930057847 Add tests to make sure discounts are rounded properly in cart. 2021-05-07 14:30:44 +05:30
roykho 2e3156d436
Use proper skip test method instead of return 2021-05-03 06:33:09 -07:00
roykho 87047c77df
Limit the new refund restock logic to order version 5.4+ 2021-04-29 06:30:53 -07:00
roykho b69f46d7d2
Add unit tests 2021-04-27 09:29:24 -07:00
Roy Ho 03d4d4893e
Merge pull request #28187 from woocommerce/fix/25900-take-2
Fix: image size customisation controls not shown when theme doesn't define them but Woo core does
2021-04-22 05:41:57 -07:00
Nestor Soriano 3a895c9eed
Move ThemeSupport class to Internal namespace, and use in 2021 theme. 2021-04-21 12:57:56 +02:00
Nestor Soriano b88eb4c981
Rename "assertIsInt" to "assertIsInteger" and make it static
- Renaming to prevent conflicts with the existing method in
  the newer PHPUnit used in PHP 8.
- Making it static because "assertIsInt" is static too, so it'll be
  easier to replace in the future.
2021-04-20 17:16:59 +02:00
Nestor Soriano d11a20b5b4
Merge branch 'trunk' into fix/25900-take-2 2021-04-20 16:08:45 +02:00
Nestor Soriano 76a613a5bb
Modify wc_get_low_stock_amount so that it always returns an integer.
Previously, if the product didn't have an explicit low stock value
amount the value of the woocommerce_notify_low_stock_amount option,
which is a string, was returned verbatim.

Also, update related unit tests to create the option value as a string,
and to check that the value returned by woocommerce_notify_low_stock_amount
is always an integer.
2021-04-20 10:17:50 +02:00
Nestor Soriano 1008835488
Fix code sniffer violations in stock functions and its tests 2021-04-20 09:42:07 +02:00
Nestor Soriano cf9300bbbc
Refactor in the WC_Settings_Page class for PHP 8 compatibility
- Turn get_settings into a parameterless method, but accept one
  parameter via func_get_arg; and mark the method as deprecated.
- Rename the existing get_settings to get_settings_for_section;
  and mark the method as final.
- Rename the existing get_settings_for_section to get_settings_for_section_core.

See the comment added to get_settings for the rationale for the change.
2021-04-13 12:45:42 +02:00
Nestor Soriano 56cc063d7f
Rename "get_settings" to "get_settings_for_section" in settings pages.
In PHP 8 overriding a method having an optional parameter with a
method having no parameters throws an error, thus we can't use
the strategy of changing "get_settings()" to "get_settings($section='')"
without breaking existing extensions. So we do the following instead:

- Rename the existing "get_settings" to "get_settings_for_section"
- Rename the existing "get_settings_for_section" to "get_settings_for_section_core"
- Add a "get_settings" that just does "get_settings_for_section('')"
  for compatibility, but mark it as deprecated.
2021-04-12 18:04:41 +02:00
Nestor Soriano ca46992c00
Adjustments in settings pages after a merge with conflicts. 2021-04-12 15:55:45 +02:00
Claudio Sanches a761e78a84
Fixed unit tests 2021-04-12 12:50:21 +02:00
Nestor Soriano 65c1c9ec54
Fix unit tests after merging from trunk 2021-04-12 12:50:21 +02:00
Nestor Soriano d820fbe4a7
Fix wrong handling of the shipping - shipping options section. 2021-04-12 12:42:40 +02:00
Nestor Soriano e5f234ec0f
Re-implement the flushing of the term count cache that was lost on merge
Also add unit tests for it.
2021-04-12 12:42:39 +02:00
Nestor Soriano 7440e95b72
Fix unit tests after merge from master 2021-04-12 12:42:39 +02:00
Nestor Soriano bcf24f0f8c
Fix unit test problems in PHP 7.0.
This includes removing two array_merge and array_merge_eecursive
statements in the code hacker, that apparently were working differently
in PHP 7.0.
2021-04-12 12:42:39 +02:00
Nestor Soriano 5a11d9e064
Refactor the settings pages, and add unit tests for them.
This commit fixes some inconsistencies in the settings pages, and
makes all the existing pages extensible by adding new sections
(that was possible in some pages, but not in others). Main changes:

1. Modify the 'get_sections' method so that it invokes a new protected
   'get_own_sections' method and then triggers the
   'woocommerce_get_sections_' . id filter.

This way the filter is triggered only in the base class
and not in each of the derived classes too.

2. Change the get_settings() method so that it has its signature
   changed to get_settings( $current_section = '' )
   in the base class and in all the derived class.

Some derived classes were already using this signature, but others
(those not having multiple sections natively) weren't, making then
effectively impossible to define multiple sections for these pages
via filters.

With this change all the section pages act consistently and allow
both adding new settings to the default "General" section
and creating new sections via filters.

3. Change the implementation of 'get_settings' in the base class
   so that it searches for a 'get_settings_for_{section_id}_section'
   method in the class and executes it, otherwise it executes the new
   protected method get_settings_for_section( $current_section ); then
   it triggers the 'woocommerce_get_settings_' . id filter.

This makes it easier to separate the code that returns the list
of filters in multiple methods, one per section, instead of using
one big if-else-else... block.

So now instead of overriding get_settings($current_section='') derived
classes need to implement get_settings_for_{$current_section}_section
for each section, or override get_settings_for_section($current_section)
or both. 'get_settings_for_section' returns an empty array by default.

Also, 'woocommerce_get_settings_' . id is triggered in one single
place too.

Other improvements:

* Remove duplicated code from 'output' in 'WC_Settings_Page' children.

Some classes inherited from 'WC_Settings_Page' override the 'output'
method with custom code, which in all cases ended up repeating the code
of the original method as a fallback. These repetitions have been
replaced with 'parent::output()'.

* Fix inconsistencies for 'save' and 'output' in WC_Settings_Tax/Emails

The 'WC_Settings_Tax' and 'WC_Settings_Emails' classes had some
inconsistencies in their 'save' and 'output' methods that prevented the
proper creation new sections and the addition of new settings via the
'woocommerce_get_sections_' and 'woocommerce_get_settings_' filters.
Now they work as expected.

* Deduplicate parts of 'save' in 'WC_Settings_Page' and children.

Two methods have been added to 'WC_Settings_Page' class:
'save_settings_for_current_section' and 'do_update_options_action'.
These are intended to be invoked by derived classes in their 'save'
methods, in order to remove code repetition.

* Add some helper methods to WC_Unit_Test_Case.

Methods added:
- assertOutputsHTML
- assertEqualsHTML
- normalize_html
- capture_output_from
2021-04-12 12:42:26 +02:00
Néstor Soriano 439d26be82
Merge pull request #29606 from woocommerce/fix/29545
Don't verify empty country codes on checkout
2021-04-08 12:40:13 +02:00
Nestor Soriano a37b2a7474
Don't verify empty country codes on checkout
PR #28849 introduced a verification of the posted country code
on checkout, so an invalid code will throw an error. However there
are cases when an empty code is legitimately received, for example
when using Paypal checkout directly from the product page and
the customer doesn't have an address in his Paypal profile.
2021-04-07 09:59:56 +02:00
𝓑𝓪𝓻𝓻𝔂 𝓗𝓾𝓰𝓱𝓮𝓼 095b3e9fb9 Merge latest changes from trunk. 2021-03-31 10:25:25 -07:00
Roy Ho e4502fe314
Merge pull request #29495 from woocommerce/fix/29472
Add "postcodes" and "cities" support for the REST API tax rate creation/update endpoint
2021-03-31 08:17:31 -07:00
Nestor Soriano 64e903f65f
Update REST API v3 taxes endpoint descriptions with deprecation/introduction information. 2021-03-31 12:41:53 +02:00
Nestor Soriano 8ff664e758
Fix "doing wrong wpdb::prepare" notice for REST API get taxes endpoint. 2021-03-31 12:09:20 +02:00
Nestor Soriano ccb8cbddac Adjust tests for WC_Admin_Dashboard_Setup (consider 'payments' task) 2021-03-29 17:39:58 +02:00