Skip to content

Commit bbd6987

Browse files
malithsenwjrosa
andauthored
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]>
1 parent 0eb61e3 commit bbd6987

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
@@ -9,6 +9,7 @@
99
* Add - Add state mapping for Lithuania in express checkout
1010
* Tweak - Use wp_ajax prefix for its built-in security for Add Payment Method action
1111
* Dev - Fix WooCommerce version fetching in GitHub workflows
12+
* Dev - Fix failing test cases associated with WooCommerce 10.0.x
1213

1314
= 9.7.0 - 2025-07-21 =
1415
* 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
@@ -119,5 +119,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
119119
* Add - Add state mapping for Lithuania in express checkout
120120
* Tweak - Use wp_ajax prefix for its built-in security for Add Payment Method action
121121
* Dev - Fix WooCommerce version fetching in GitHub workflows
122+
* Dev - Fix failing test cases associated with WooCommerce 10.0.x
122123

123124
[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

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)