Commit f489f246aee for woocommerce
commit f489f246aeee82d14a095a45e650f0a0410b8dd9
Author: Luis Felipe Zaguini <26530524+zaguiini@users.noreply.github.com>
Date: Tue Nov 3 16:14:22 2026 -0300
Enable taxes in the prices_include_tax order tests (#70598)
* Apply test bootstrap option overrides after the WooCommerce install
The test bootstrap set woocommerce_calc_taxes and two other options in
load_wc(). install_wc() then runs uninstall.php, which deletes every
woocommerce_ option, and WC_Install::install() writes the defaults back.
Unit tests therefore started with taxes disabled. Set the overrides after
the install so they hold.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Enable taxes in the prices_include_tax order tests
Moving the bootstrap overrides after the install enabled taxes for the
whole suite and broke five tests that assume taxes are off. Keep the
bootstrap as it was and enable taxes in the three tests that need them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/fix-test-bootstrap-tax-options b/plugins/woocommerce/changelog/fix-test-bootstrap-tax-options
new file mode 100644
index 00000000000..6eae8d94c2d
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-test-bootstrap-tax-options
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Enable taxes in the prices_include_tax order tests instead of relying on state leaked from other test classes.
+
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/Orders/PageControllerTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/Orders/PageControllerTest.php
index 2363495ba1b..908fe121bda 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/Orders/PageControllerTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/Orders/PageControllerTest.php
@@ -220,11 +220,13 @@ namespace Automattic\WooCommerce\Tests\Internal\Admin\Orders {
$previous_theorder = $theorder ?? null;
$previous_get = $_GET; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$previous_tax_mode = get_option( 'woocommerce_prices_include_tax' );
+ $previous_calc_tax = get_option( 'woocommerce_calc_taxes' );
$previous_currency = get_option( 'woocommerce_currency' );
$order_id = 0;
try {
$this->toggle_cot_feature_and_usage( true );
+ update_option( 'woocommerce_calc_taxes', 'yes' );
update_option( 'woocommerce_prices_include_tax', $tax_mode );
update_option( 'woocommerce_currency', 'EUR' );
set_current_screen();
@@ -270,6 +272,7 @@ namespace Automattic\WooCommerce\Tests\Internal\Admin\Orders {
}
update_option( 'woocommerce_prices_include_tax', $previous_tax_mode );
+ update_option( 'woocommerce_calc_taxes', $previous_calc_tax );
update_option( 'woocommerce_currency', $previous_currency );
if ( $had_pagenow ) {
diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php
index d53802a2cc9..129c334b75a 100644
--- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php
+++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php
@@ -2618,9 +2618,11 @@ class OrdersTableDataStoreTests extends \HposTestCase {
*/
public function test_create_without_explicit_prices_include_tax_keeps_default(): void {
$previous_tax_mode = get_option( 'woocommerce_prices_include_tax' );
+ $previous_calc_tax = get_option( 'woocommerce_calc_taxes' );
$order = null;
try {
+ update_option( 'woocommerce_calc_taxes', 'yes' );
update_option( 'woocommerce_prices_include_tax', 'yes' );
$order = new WC_Order();
update_option( 'woocommerce_prices_include_tax', 'no' );
@@ -2644,6 +2646,7 @@ class OrdersTableDataStoreTests extends \HposTestCase {
$order->delete( true );
}
update_option( 'woocommerce_prices_include_tax', $previous_tax_mode );
+ update_option( 'woocommerce_calc_taxes', $previous_calc_tax );
}
}
@@ -2687,9 +2690,11 @@ class OrdersTableDataStoreTests extends \HposTestCase {
global $wpdb;
$previous_tax_mode = get_option( 'woocommerce_prices_include_tax' );
+ $previous_calc_tax = get_option( 'woocommerce_calc_taxes' );
$order = new WC_Order();
try {
+ update_option( 'woocommerce_calc_taxes', 'yes' );
update_option( 'woocommerce_prices_include_tax', 'yes' );
$this->switch_data_store( $order, $this->sut );
$order->save();
@@ -2716,6 +2721,7 @@ class OrdersTableDataStoreTests extends \HposTestCase {
} finally {
$order->delete( true );
update_option( 'woocommerce_prices_include_tax', $previous_tax_mode );
+ update_option( 'woocommerce_calc_taxes', $previous_calc_tax );
}
}