Commit Graph

3324 Commits

Author SHA1 Message Date
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 8a60e7e147
Move code hacker resetting from BeforeTestHook to setUp
The code hacker needs to be reset before each test. This was done via
a couple of classes implementeing BeforeTestHook, those were registered
in phpunit.xml.

The problem is that the PHPUnit version used for WooCommerce unit test
has recently been changed from 7.5 to 6.5 for compatibility with
PHP 7.0, and hook classes were introduced in PHPUnit 7. Thus no hooks
were ran, the code hacker wasn't reset, that caused some functions
to remain hacked between tests, and this made some tests to fail.

The solution is to move the code hacker reset to the setUp method
in the base unit test class.
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
Veljko bdd9fe7318 Add waitForNavigation on Continue clicking 2021-04-09 11:48:17 +02:00
Veljko bc40163155 Make the test more granular 2021-04-08 19:01:54 +02:00
Veljko fc14a4e5da Add missing beforeAll code 2021-04-08 17:20:03 +02:00
Tam Mullen 59ed09157b
Merge pull request #29426 from woocommerce/e2e/e2e-merchant-import-products
Add new e2e test merchant import products via CSV file
2021-04-08 14:46:31 +01: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
Roy Ho 8052fbe7be
Merge pull request #29605 from woocommerce/fix/28759-billing-shipping-addresses
Fix/28759 billing shipping addresses
2021-04-07 14:34:01 -07:00
Claudio Sanches ec77c3bcc9
Merge pull request #29603 from masteradhoc/masteradhoc-accessibility-strikethrough-price
Improve WooCommerce Accessibility - Strikethrough Price
2021-04-07 13:41:08 -03: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
Barry Hughes 87cdcff52d Merge branch 'trunk' into fix/28759-billing-shipping-addresses 2021-04-06 17:22:52 -07:00
Brian 778cf448cb
Update data.php
fix legacy code test
2021-04-06 23:56:28 +02:00
Brian 50b882905f
Update data.php
fix legacy tests
2021-04-06 23:44:36 +02:00
Brian 913c46ac91
Update functions.php
fix legacy test
2021-04-06 23:43:53 +02:00
Veljko V be44da32de
Merge pull request #29551 from woocommerce/fix/allow-local-slackbot
Allow local slackbot
2021-04-06 16:35:48 +02:00
Greg 5aeafe56eb
Merge pull request #29571 from woocommerce/add/smoke-test-daily
add smoke test daily log in
2021-04-05 13:32:22 -06:00
Ron Rennick 8bfb2fa8df
Merge pull request #29544 from woocommerce/fix/empty-cart-remove-coupons
Remove all coupons before each test run, and clear cart
2021-04-05 16:11:38 -03:00
Veljko V 701d7fa183
Merge branch 'trunk' into e2e/e2e-merchant-import-products 2021-04-05 17:50:32 +02:00
Veljko 9d1b347148 Add spacing and missing await 2021-04-05 11:25:15 +02:00
Veljko V b850ba3f84
Merge branch 'trunk' into e2e/e2e-merchant-import-products 2021-04-02 09:52:45 +02:00
Veljko V 93ceea1854
Merge branch 'trunk' into e2e/e2e-shopper-login-checkout 2021-04-02 09:51:52 +02:00
Ron Rennick 9355c92231 add smoke test daily log in 2021-04-01 21:55:38 -03:00
Greg e39f2ecd4f
Merge pull request #29565 from woocommerce/e2e/e2e-shopper-my-account-create
Added new e2e test my account create account
2021-04-01 15:44:05 -06:00
zhongruige b1d0f4eab0 Add missing semicolon 2021-04-01 12:51:04 -06:00
Ron Rennick a5b612b0a8 Merge branch 'trunk' into fix/allow-local-slackbot 2021-04-01 14:48:46 -03:00
Veljko daf41aadb9 Merge branch 'trunk' into e2e/e2e-shopper-login-checkout 2021-04-01 19:35:29 +02:00
Greg e5c2e32a7b
Merge pull request #29549 from woocommerce/e2e/e2e-fix-flaky-order-searching
Fix flakiness in Merchant's Order Searching test
2021-04-01 11:29:08 -06:00
Greg a4ef0b0b1d
Merge pull request #29548 from woocommerce/e2e/e2e-fix-flaky-shipping-zones
Fix flakiness in Merchant's Add Shipping Zones test
2021-04-01 11:02:00 -06:00
Ron Rennick 13f6cf4819
Merge pull request #29557 from woocommerce/fix/e2e-onboarding-fkakiness
Fix for e2e flakiness in onboarding wizard
2021-04-01 12:51:43 -03:00
Veljko 29f47f2289 Fixed spaces in the code 2021-04-01 16:24:26 +02:00
Veljko 1676c0d8a3 Added new e2e test shopper create account 2021-04-01 15:38:53 +02:00
Veljko eb6572fec0 Added new e2e test shopper login checkout 2021-04-01 11:10:43 +02:00
Roy Ho 8b6e4ac519
Merge pull request #29542 from woocommerce/fix/23682.1
Update UID only for WooCommerce cookies
2021-03-31 16:05:28 -07:00
zhongruige beb63625ac Use checkbox specific utils and verify it's checked before continuing 2021-03-31 14:26:36 -06:00
𝓑𝓪𝓻𝓻𝔂 𝓗𝓾𝓰𝓱𝓮𝓼 095b3e9fb9 Merge latest changes from trunk. 2021-03-31 10:25:25 -07:00
Veljko 6cb79fb90d Improve test and fix flakiness 2021-03-31 17:59:09 +02: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
Veljko f882aba670 Another attempt to fix flakiness 2021-03-31 16:50:41 +02:00
Veljko b2dd7f9057 Add type instead of select 2021-03-31 16:06:07 +02:00
Ron Rennick 8cb816add9 silence channel_not_found warning 2021-03-31 10:08:00 -03:00
Ron Rennick a720f00a2d allow slackbot to function from local environment 2021-03-31 10:00:42 -03:00
Veljko 4e1b24044f Fix flakiness in the test 2021-03-31 13:59:00 +02:00