- 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.
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.
- 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.
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.
- 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`.