@@ -48,6 +48,16 @@ public function set_up() {
4848 ->willReturn ( false );
4949
5050 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+ );
5161 }
5262
5363 public function tear_down () {
@@ -66,6 +76,9 @@ function ( $key ) {
6676
6777 // Restore the cache service in the main class.
6878 WC_Payments::set_database_cache ( $ this ->_cache );
79+
80+ remove_all_filters ( 'woocommerce_available_payment_gateways ' );
81+
6982 parent ::tear_down ();
7083 }
7184
@@ -208,6 +221,12 @@ public function test_is_woopay_enabled_returns_false_when_ineligible() {
208221 $ this ->assertFalse ( WC_Payments_Features::is_woopay_enabled () );
209222 }
210223
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+
211230 public function test_is_woopay_express_checkout_enabled_returns_true () {
212231 $ this ->set_feature_flag_option ( WC_Payments_Features::WOOPAY_EXPRESS_CHECKOUT_FLAG_NAME , '1 ' );
213232 $ this ->mock_cache ->method ( 'get ' )->willReturn ( [ 'platform_checkout_eligible ' => true ] );
@@ -238,6 +257,12 @@ public function test_is_woopay_direct_checkout_enabled_returns_true() {
238257 $ this ->assertTrue ( WC_Payments_Features::is_woopay_direct_checkout_enabled () );
239258 }
240259
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+
241266 public function test_is_woopay_direct_checkout_enabled_returns_false_when_flag_is_false () {
242267 $ this ->set_feature_flag_option ( WC_Payments_Features::WOOPAY_EXPRESS_CHECKOUT_FLAG_NAME , '1 ' );
243268 $ this ->set_feature_flag_option ( WC_Payments_Features::WOOPAY_DIRECT_CHECKOUT_FLAG_NAME , '0 ' );
0 commit comments