Skip to content

Commit ab03cb2

Browse files
malithsendaledupreez
authored andcommitted
Fix failing unit tests on WC 10.0.* (#4517)
* Fix version sorting * Add changelog entry * Update changelog entry * Update changelog entry * Update code comment * Fix changelogs * Compare order ID instead of the entire object * Use version_compare * Exclude wc=L-1 + WP=L-2 from test matrix * Update excluded versions * Add changelog entries --------- Co-authored-by: Wesley Rosa <[email protected]> Cherry-picked from bbd6987
1 parent 077509c commit ab03cb2

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

.github/workflows/php-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
exclude: # incompatible versions of PHP, WordPress, and WooCommerce
7272
- woocommerce_support_policy: L
7373
wordpress_support_policy: L-2
74+
- woocommerce_support_policy: L-1
75+
wordpress_support_policy: L-2
7476

7577
name: Stable (PHP=${{ matrix.php_support_policy }}, WP=${{ matrix.wordpress_support_policy }}, WC=${{ matrix.woocommerce_support_policy }})
7678
env:

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Fix - Fix required field error message and PHP warning for custom checkout fields that don't have a label
88
* Fix - Fix fatal when processing setup intents for free subscriptions via webhooks
99
* Dev - Fix WooCommerce version fetching in GitHub workflows
10+
* Dev - Fix failing test cases associated with WooCommerce 10.0.x
1011

1112
= 9.7.0 - 2025-07-21 =
1213
* Update - Removes BNPL payment methods (Klarna and Affirm) when other official plugins are active

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
117117
* Fix - Fix required field error message and PHP warning for custom checkout fields that don't have a label
118118
* Fix - Fix fatal when processing Boleto setup intents via webhooks
119119
* Dev - Fix WooCommerce version fetching in GitHub workflows
120+
* Dev - Fix failing test cases associated with WooCommerce 10.0.x
120121

121122
= 9.7.0 - 2025-07-21 =
122123

tests/phpunit/PaymentMethods/WC_Stripe_UPE_Payment_Gateway_Test.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,11 @@ public function test_process_payment_returns_valid_response() {
440440
->with(
441441
"payment_intents/$payment_intent_id",
442442
$expected_request,
443-
wc_get_order( $order_id )
443+
$this->callback(
444+
function ( $passed_order ) use ( $order ) {
445+
return $order->get_id() === $passed_order->get_id();
446+
}
447+
)
444448
)
445449
->will(
446450
$this->returnValue( [] )
@@ -1979,7 +1983,11 @@ public function test_if_order_has_subscription_payment_method_will_be_saved() {
19791983
->with(
19801984
"payment_intents/$payment_intent_id",
19811985
$expected_request,
1982-
wc_get_order( $order_id )
1986+
$this->callback(
1987+
function ( $passed_order ) use ( $order ) {
1988+
return $order->get_id() === $passed_order->get_id();
1989+
}
1990+
)
19831991
)
19841992
->will(
19851993
$this->returnValue( [] )

tests/phpunit/WC_Stripe_Co_Branded_CC_Compatibility_Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ class WC_Stripe_Co_Branded_CC_Compatibility_Test extends WP_UnitTestCase {
1818
*/
1919
public function test_is_wc_supported() {
2020
$helper = new WC_Stripe_Co_Branded_CC_Compatibility();
21-
$this->assertSame( defined( 'WC_VERSION' ) && WC_VERSION > WC_Stripe_Co_Branded_CC_Compatibility::MIN_WC_VERSION, $helper->is_wc_supported() );
21+
$this->assertSame( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, WC_Stripe_Co_Branded_CC_Compatibility::MIN_WC_VERSION, '>' ), $helper->is_wc_supported() );
2222
}
2323
}

0 commit comments

Comments
 (0)