@@ -48,6 +48,16 @@ public function set_up() {
48
48
->willReturn ( false );
49
49
50
50
WC_Payments::set_account_service ( $ this ->mock_wcpay_account );
51
+
52
+ add_filter (
53
+ 'woocommerce_available_payment_gateways ' ,
54
+ function () {
55
+ return [
56
+ 'woocommerce_payments ' => new class () extends WC_Payment_Gateway {
57
+ },
58
+ ];
59
+ }
60
+ );
51
61
}
52
62
53
63
public function tear_down () {
@@ -66,6 +76,9 @@ function ( $key ) {
66
76
67
77
// Restore the cache service in the main class.
68
78
WC_Payments::set_database_cache ( $ this ->_cache );
79
+
80
+ remove_all_filters ( 'woocommerce_available_payment_gateways ' );
81
+
69
82
parent ::tear_down ();
70
83
}
71
84
@@ -208,6 +221,12 @@ public function test_is_woopay_enabled_returns_false_when_ineligible() {
208
221
$ this ->assertFalse ( WC_Payments_Features::is_woopay_enabled () );
209
222
}
210
223
224
+ public function test_is_woopay_enabled_returns_false_when_woopayments_is_disabled () {
225
+ remove_all_filters ( 'woocommerce_available_payment_gateways ' );
226
+
227
+ $ this ->assertFalse ( WC_Payments_Features::is_woopay_enabled () );
228
+ }
229
+
211
230
public function test_is_woopay_express_checkout_enabled_returns_true () {
212
231
$ this ->set_feature_flag_option ( WC_Payments_Features::WOOPAY_EXPRESS_CHECKOUT_FLAG_NAME , '1 ' );
213
232
$ this ->mock_cache ->method ( 'get ' )->willReturn ( [ 'platform_checkout_eligible ' => true ] );
@@ -238,6 +257,12 @@ public function test_is_woopay_direct_checkout_enabled_returns_true() {
238
257
$ this ->assertTrue ( WC_Payments_Features::is_woopay_direct_checkout_enabled () );
239
258
}
240
259
260
+ public function test_is_woopay_direct_checkout_enabled_returns_false_when_woopayments_is_disabled () {
261
+ remove_all_filters ( 'woocommerce_available_payment_gateways ' );
262
+
263
+ $ this ->assertFalse ( WC_Payments_Features::is_woopay_direct_checkout_enabled () );
264
+ }
265
+
241
266
public function test_is_woopay_direct_checkout_enabled_returns_false_when_flag_is_false () {
242
267
$ this ->set_feature_flag_option ( WC_Payments_Features::WOOPAY_EXPRESS_CHECKOUT_FLAG_NAME , '1 ' );
243
268
$ this ->set_feature_flag_option ( WC_Payments_Features::WOOPAY_DIRECT_CHECKOUT_FLAG_NAME , '0 ' );
0 commit comments