Commit Graph

34917 Commits

Author SHA1 Message Date
Julia Amosova 4756d4c911 Add asterisk to star ratings if required checkbox is enabled 2020-05-24 18:27:08 -04:00
Renovate Bot 4d4e327df6
Update dependency woocommerce/woocommerce-admin to v1.2.3 2020-05-22 19:24:14 +00:00
vedanshujain 57d336433a Fix regression caused by merging #25092 conflicting with #24828 2020-05-22 22:08:42 +05:30
Christopher Allford 1d216d3a98
Merge pull request #26559 from woocommerce/fix/update-jp-autoloader
Updated the Jetpack Autoloader
2020-05-22 07:13:26 -07:00
vedanshujain 418741a0b2 Add unit test for verify_base_tables function 2020-05-22 18:32:04 +05:30
vedanshujain fafa44bde0 Modified notice to also handle when REST API does not have verify tool. 2020-05-22 18:32:03 +05:30
vedanshujain f5afddd4c9 Add support for notices 2020-05-22 18:32:03 +05:30
vedanshujain 3acc03c804 Add `verify_base_db` method to check if all base tables are present.
Optionally, also adds a notice in case all db tables are not present. Returns list of tables.

Note that we only check missing tables and don't care about exact table structure because many time tables are modified by merchants to better suit their needs (indexes, collations etc).
2020-05-22 18:30:11 +05:30
Christopher Allford 93811e0a56
Merge pull request #25753 from woocommerce/fix/25752-wc_get_shipping_method_count-check-enabled
Add is_enabled=1 check in wc_get_shipping_method_count()
2020-05-21 11:44:36 -07:00
Christopher Allford 2953df2c5d
Merge pull request #26529 from woocommerce/fix/e2e-403-errors
use nonced logout link for store owner logout
2020-05-21 10:44:10 -07:00
Ron Rennick 47aab8c56b
Merge pull request #26522 from woocommerce/tweak/e2e-tests-suite
Tweaks to e2e tests suite README
2020-05-21 13:15:04 -03:00
Nestor Soriano 2a68bb018d Move testing tools to the tests/Tools directory
The testing tools (only the code hacker at this time) have been moved
from 'src' to 'tests/Tools', since many opcode cache plugins
load the whole src folder in production.

Also, an extra autoloader is set in the tests bootstrap so that
the 'tests/Tools' directory corresponds, using PSR4, to the
'Automattic\WooCommerce\Testing\Tools' namespace.
2020-05-20 09:57:39 +02:00
Nestor Soriano 0726f71aac Small improvements in the code hacker
- Convert a hardcoded number to a constant
- Add more information to an exception message
- Remove unnecessary PHPCS disabling
- Throw exception on PHP<7.0
2020-05-20 09:56:26 +02:00
Nestor Soriano 8a7d955253 Improvements on the code hacker.
- Add methods to temporarily disable and reenable the code hacker.

The code hacker is causing issues in some tests that perform
write operations to the local filesystem. Since this happens only
in a few cases, the easiest fix is to temporarily disable the
code hacker when that happens. This commit adds two new methods
for that in `WC_Unit_Test_Case`: `disable_code_hacker` and
`reenable_code_hacker`.

These methods use a disabling requests count so that the hacker
isn't enabled before it should. E.g. you call `disable`, then
a helper method that does `disable` and `enable`, then `enable` -
then only the last `enable` will have effect.

- `CodeHacker::add_hack` has now a boolean `persistent` parameter.
Persistent hacks won't be cleared by `clear_hacks`.

- `CodeHackerTestHook::executeAfterTest` will now disable the hacker
only if no persistent hacks are registered.

- The existing `file_copy` method is made static for consistency.

- `CodeHacker::restore` method renamed to `disable` for clarity.
2020-05-20 09:56:26 +02:00
Nestor Soriano 6f2e0bf694 Improve error messaging in WC_Tests_MaxMind_Database::test_download_database_works 2020-05-20 09:56:25 +02:00
Nestor Soriano f04089d572 Add function docs to the CodeHacker class. 2020-05-20 09:56:25 +02:00
Nestor Soriano 884fd08462 Add a workaround for code hacking static methods on already loaded files.
The unit testing bootstrap loads and initializes WooCommerce, this
loads a bunch of code files that can't then be hacked in the test hooks.

A workaround is provided in this commit for the case of hacking
static methods. A new StaticWrapper class is created that allows
defining mock methods after the code file has been loaded.
This is applied to all classes from a fixed list in the bootstrap,
before WooCommerce is initialized. The list should be kept up to date
with the list of classes that require such workaround.
2020-05-20 09:56:25 +02:00
Nestor Soriano c7cf39bef4 Add a README file for the code hacker. 2020-05-20 09:56:25 +02:00
Nestor Soriano f0b0822c1c Fix code sniffer errors in CodeHacker and related classes. 2020-05-20 09:56:25 +02:00
Nestor Soriano 57845ef8b8 All code hacking files moved to src\Testing folder. 2020-05-20 09:56:25 +02:00
Nestor Soriano 1a68abbc28 Miscellaneous code hacking fixes:
- Fix how CodeHackerTestHook::executeBeforeTest parses the test name,
  to account for warnings and tests with data sets.

- CodeHackerTestHook now includes a executeAfterTest hook that
  disables the code hacker (needed to prevent it from inadvertently
  altering further tests). Also, clear_hacks is executed in
  executeBeforeTest for the same reason.

- CodeHacker gets restore, clear_hacks and is_enabled methods
  to support the changes in CodeHackerTestHook.

- FunctionsMockerHack fixed so that it doesn't modify strings
  that are class method definitions.

- Added the WC_Unit_Test_Case::file_copy method, it must be used
  instead of the PHP built-in "copy" in tests, otherwise tests
  that run with the code hacker active will fail.
  This is something to investigate.
2020-05-20 09:56:25 +02:00
Nestor Soriano 9a5b3b353d Add the @hack code annotation for tests.
Now @hack class and method annotations can be used to register
code hacks as an alternative to using before_ methods.
The syntax is /* @hack HackClassName param1 param2 */
where parameters will be passed to the class constructor.
If the class name ends with "Hack", then that suffix can be
omitted (e.g. "Foo" can be specified instead of "FooHack").
2020-05-20 09:56:25 +02:00
Nestor Soriano db58b51de3 Barebones implementation of a code hacker for unit tests.
The "code hacker" is a class that hooks on filesystem events
(using stream_wrapper_unregister) in order to allow for dynamically
modifying the content of PHP code files while they are loaded.
The code hacker class allows registering hacks, which are
functions that take source code as input and return the modified code.
A hack can be a standalone function or a class with a "hack" method.

A few hacks are provided off the shelf. One allows mocking standalone
PHP functions (WP, WOO or not), another one allows mocking static
methods, and there's the one that removes the "final" qualifier
from a class definition. This helps unit testing stuff that would
otherwise be quite hard to test.
2020-05-20 09:56:25 +02:00
Christopher Allford 326d8feb92 Updated the Jetpack Autoloader
Jetpack made a change that requires some extra ignore entries from the latest release of the autoloader, otherwise debug logging warnings are thrown.
2020-05-19 16:16:50 -07:00
Christopher Allford 4750a2d567
Merge pull request #26550 from woocommerce/fix/update-wp-minimum
Adhere to WP support policy
2020-05-19 09:21:09 -07:00
Vedanshu Jain 12ff70fb14
Merge pull request #26549 from woocommerce/fix/26493-error-handling
Call callback on tracking script load error
2020-05-19 21:09:06 +05:30
Joshua Flowers b7bca44beb Call callback on tracking script load error 2020-05-19 18:19:19 +03:00
Christopher Allford df7db72855 Cleaned up our Travis config to suit the WP support policy 2020-05-19 07:00:32 -07:00
Christopher Allford 7db709957b Increased the WordPress minimum version to 5.2 as per our support policy 2020-05-19 06:59:52 -07:00
Vedanshu Jain 5adaa5667e
Merge pull request #26493 from woocommerce/fix/26466
Add function to allow client-side enabling of tracks
2020-05-19 16:30:45 +05:30
Vedanshu Jain 7fb1079137
Merge pull request #26399 from woocommerce/fix/uploads_htaccess
Disable directory listing for redirect download method
2020-05-19 15:56:37 +05:30
Boro Sitnikovski d1ac3731a5 Add actions before/after shipping calculation 2020-05-18 21:04:13 +02:00
Joshua Flowers 07b1887c2b Use var instead of const 2020-05-18 19:11:29 +03:00
Ron Rennick 617a523057 fix merge conflicts 2020-05-18 12:34:03 -03:00
Claudio Sanches eea062f9fa
Merge pull request #26519 from woocommerce/fix/csv-import-special-columns
Fixed the case conversion for meta key column mapping in product CSV imports
2020-05-18 11:33:50 -03:00
Peter Fabian e3e72e0423
Merge pull request #26500 from woocommerce/fix/26443
Refresh db update nonce on the Thank you notice
2020-05-18 14:36:13 +02:00
Ron Rennick 07c6075dde use nonced logout link for store owner logout 2020-05-15 16:58:50 -03:00
Albert Juhé Lluveras 9a34c4fe75 Update WC shipping settings so no shipping zones banner appears when all are deactivated 2020-05-15 16:32:12 +02:00
Néstor Soriano 8b0d4ef050
Merge pull request #26386 from woocommerce/fix/26355
Set an error ID for each WP_Error entry
2020-05-15 12:09:14 +02:00
Boro Sitnikovski f34e73d402 Add a comment on @babel/preset-env 2020-05-15 11:28:21 +02:00
Albert Juhé Lluveras 973e50ab64 Add param to wc_get_shipping_method_count() 2020-05-15 11:22:28 +02:00
Boro Sitnikovski ad3b9fc861 Fix version mismatch error 2020-05-15 11:21:59 +02:00
Boro Sitnikovski b01f3aae93 Add some additional information and be specific about babel file 2020-05-15 11:21:34 +02:00
Albert Juhé Lluveras de7ca06b41 Set is_enabled=1 instead of is_enabled=true 2020-05-15 11:02:12 +02:00
Albert Juhé Lluveras 33b0bef8c5 Add is_enabled=true check in wc_get_shipping_method_count() 2020-05-15 11:02:12 +02:00
Néstor Soriano 3d2927f6e1
Merge pull request #26407 from woocommerce/feature/build-zip
Introduced script to generate a zip package
2020-05-15 10:59:04 +02:00
Néstor Soriano eab8920a07
Merge pull request #26314 from woocommerce/add/build-workflow
Build release workflow
2020-05-15 10:36:34 +02:00
Peter Fabian 0934f4a147 Merged should_show_notice and show_reminder and simplified logic.
Removed redundant calls to the same functions as this code runs on each admin pageload.
2020-05-15 10:24:30 +02:00
Néstor Soriano b9875a4fc1
Merge pull request #26445 from tsteur/issue_26414
Add hooks to "Add payment method form" to show additional fields and validate input
2020-05-15 10:16:53 +02:00
Peter Fabian 2f141eca77 PHPCS 2020-05-15 09:40:23 +02:00