@@ -376,6 +376,61 @@ public function test_update_settings_fails_if_user_cannot_manage_woocommerce() {
376
376
remove_filter ( 'user_has_cap ' , $ cb );
377
377
}
378
378
379
+ /**
380
+ * Tests that Apple Pay and Google Pay can be enabled in the PMC
381
+ * when payment request is enabled, and card is enabled.
382
+ */
383
+ public function test_update_settings_enables_apple_pay_google_pay () {
384
+ // Before the update: card and CashApp are enabled, Apple Pay and Google Pay are disabled
385
+ $ this ->mock_payment_method_configurations (
386
+ [ WC_Stripe_Payment_Methods::CARD , WC_Stripe_Payment_Methods::CASHAPP_PAY ],
387
+ [ WC_Stripe_Payment_Methods::APPLE_PAY , WC_Stripe_Payment_Methods::GOOGLE_PAY ]
388
+ );
389
+
390
+ // After the update: card, Apple Pay, and Google Pay are enabled, CashApp is disabled
391
+ $ this ->expect_payment_method_configurations_update (
392
+ [ WC_Stripe_Payment_Methods::CARD , WC_Stripe_Payment_Methods::APPLE_PAY , WC_Stripe_Payment_Methods::GOOGLE_PAY ],
393
+ [ WC_Stripe_Payment_Methods::CASHAPP_PAY ]
394
+ );
395
+ $ request = new WP_REST_Request ( 'POST ' , self ::SETTINGS_ROUTE );
396
+ // Disable CashApp, keep card enabled.
397
+ $ request ->set_param ( 'enabled_payment_method_ids ' , [ WC_Stripe_Payment_Methods::CARD ] );
398
+ $ request ->set_param ( 'is_upe_enabled ' , true );
399
+ // Enable Apple Pay and Google Pay.
400
+ $ request ->set_param ( 'is_payment_request_enabled ' , true );
401
+
402
+ $ response = $ this ->controller ->update_settings ( $ request );
403
+ $ this ->assertEquals ( 200 , $ response ->get_status () );
404
+ }
405
+
406
+ /**
407
+ * Tests that Apple Pay and Google Pay can only be enabled in the PMC
408
+ * when payment request is enabled, and card is enabled.
409
+ */
410
+ public function test_update_settings_enforces_apple_pay_google_pay_requires_card () {
411
+ // Before the update: card, Apple Pay, and Google Pay are enabled, CashApp is disabled
412
+ $ this ->mock_payment_method_configurations (
413
+ [ WC_Stripe_Payment_Methods::CARD , WC_Stripe_Payment_Methods::APPLE_PAY , WC_Stripe_Payment_Methods::GOOGLE_PAY ],
414
+ [ WC_Stripe_Payment_Methods::CASHAPP_PAY ]
415
+ );
416
+
417
+ // After the update: CashApp is enabled, card, Apple Pay, and Google Pay are disabled
418
+ $ this ->expect_payment_method_configurations_update (
419
+ [ WC_Stripe_Payment_Methods::CASHAPP_PAY ],
420
+ [ WC_Stripe_Payment_Methods::CARD , WC_Stripe_Payment_Methods::APPLE_PAY , WC_Stripe_Payment_Methods::GOOGLE_PAY ]
421
+ );
422
+
423
+ $ request = new WP_REST_Request ( 'POST ' , self ::SETTINGS_ROUTE );
424
+ // Disable card, enable CashApp.
425
+ $ request ->set_param ( 'enabled_payment_method_ids ' , [ WC_Stripe_Payment_Methods::CASHAPP_PAY ] );
426
+ $ request ->set_param ( 'is_upe_enabled ' , true );
427
+ // Enable Apple Pay and Google Pay -- this will be ignored because card is disabled
428
+ $ request ->set_param ( 'is_payment_request_enabled ' , true );
429
+
430
+ $ response = $ this ->controller ->update_settings ( $ request );
431
+ $ this ->assertEquals ( 200 , $ response ->get_status () );
432
+ }
433
+
379
434
/**
380
435
* Tests for the dismiss notice endpoint.
381
436
*
0 commit comments