12
12
use WCPay \Database_Cache ;
13
13
use WCPay \Duplicate_Payment_Prevention_Service ;
14
14
use WCPay \Payment_Methods \Eps_Payment_Method ;
15
- use WCPay \Payment_Methods \UPE_Payment_Gateway ;
16
15
use WCPay \Payment_Methods \CC_Payment_Method ;
17
16
use WCPay \Payment_Methods \Bancontact_Payment_Method ;
18
17
use WCPay \Payment_Methods \Becs_Payment_Method ;
@@ -65,34 +64,6 @@ class WC_REST_Payments_Settings_Controller_Test extends WCPAY_UnitTestCase {
65
64
*/
66
65
private $ mock_db_cache ;
67
66
68
- /**
69
- * An array of mocked split UPE payment gateways mapped to payment method ID.
70
- *
71
- * @var UPE_Payment_Gateway
72
- */
73
- private $ mock_upe_payment_gateway ;
74
-
75
- /**
76
- * An array of mocked split UPE payment gateways mapped to payment method ID.
77
- *
78
- * @var UPE_Payment_Gateway
79
- */
80
- private $ mock_split_upe_payment_gateway ;
81
-
82
- /**
83
- * UPE system under test.
84
- *
85
- * @var WC_REST_Payments_Settings_Controller
86
- */
87
- private $ upe_controller ;
88
-
89
- /**
90
- * UPE system under test.
91
- *
92
- * @var WC_REST_Payments_Settings_Controller
93
- */
94
- private $ upe_split_controller ;
95
-
96
67
/**
97
68
* WC_Payments_Localization_Service instance.
98
69
*
@@ -186,40 +157,6 @@ public function set_up() {
186
157
);
187
158
$ this ->controller = new WC_REST_Payments_Settings_Controller ( $ this ->mock_api_client , $ this ->gateway , $ this ->mock_wcpay_account );
188
159
189
- $ this ->mock_upe_payment_gateway = new WC_Payment_Gateway_WCPay (
190
- $ this ->mock_api_client ,
191
- $ this ->mock_wcpay_account ,
192
- $ customer_service ,
193
- $ token_service ,
194
- $ action_scheduler_service ,
195
- $ mock_payment_method ,
196
- $ mock_payment_methods ,
197
- $ mock_rate_limiter ,
198
- $ order_service ,
199
- $ mock_dpps ,
200
- $ this ->mock_localization_service ,
201
- $ this ->mock_fraud_service
202
- );
203
-
204
- $ this ->upe_controller = new WC_REST_Payments_Settings_Controller ( $ this ->mock_api_client , $ this ->mock_upe_payment_gateway , $ this ->mock_wcpay_account );
205
-
206
- $ this ->mock_split_upe_payment_gateway = new WC_Payment_Gateway_WCPay (
207
- $ this ->mock_api_client ,
208
- $ this ->mock_wcpay_account ,
209
- $ customer_service ,
210
- $ token_service ,
211
- $ action_scheduler_service ,
212
- $ mock_payment_methods ['card ' ],
213
- $ mock_payment_methods ,
214
- $ mock_rate_limiter ,
215
- $ order_service ,
216
- $ mock_dpps ,
217
- $ this ->mock_localization_service ,
218
- $ this ->mock_fraud_service
219
- );
220
-
221
- $ this ->upe_split_controller = new WC_REST_Payments_Settings_Controller ( $ this ->mock_api_client , $ this ->mock_split_upe_payment_gateway , $ this ->mock_wcpay_account );
222
-
223
160
$ this ->mock_api_client
224
161
->method ( 'is_server_connected ' )
225
162
->willReturn ( true );
@@ -269,7 +206,7 @@ public function test_get_settings_returns_enabled_payment_method_ids() {
269
206
);
270
207
}
271
208
272
- public function test_upe_get_settings_returns_available_payment_method_ids () {
209
+ public function test_get_settings_returns_available_payment_method_ids () {
273
210
$ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn (
274
211
[
275
212
'currency_code ' => 'usd ' ,
@@ -295,32 +232,6 @@ public function test_upe_get_settings_returns_available_payment_method_ids() {
295
232
);
296
233
}
297
234
298
- public function test_split_upe_get_settings_returns_available_payment_method_ids () {
299
- $ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn (
300
- [
301
- 'currency_code ' => 'usd ' ,
302
- ]
303
- );
304
- $ response = $ this ->upe_split_controller ->get_settings ();
305
- $ enabled_method_ids = $ response ->get_data ()['available_payment_method_ids ' ];
306
-
307
- $ this ->assertEquals (
308
- [
309
- Payment_Method::CARD ,
310
- Payment_Method::BECS ,
311
- Payment_Method::BANCONTACT ,
312
- Payment_Method::EPS ,
313
- Payment_Method::GIROPAY ,
314
- Payment_Method::IDEAL ,
315
- Payment_Method::SOFORT ,
316
- Payment_Method::SEPA ,
317
- Payment_Method::P24 ,
318
- Payment_Method::LINK ,
319
- ],
320
- $ enabled_method_ids
321
- );
322
- }
323
-
324
235
public function test_get_settings_request_returns_test_mode_flag () {
325
236
$ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn (
326
237
[
@@ -438,26 +349,15 @@ public function test_update_settings_returns_error_on_non_bool_is_wcpay_enabled_
438
349
$ this ->assertEquals ( 400 , $ response ->get_status () );
439
350
}
440
351
441
- public function test_upe_update_settings_saves_enabled_payment_methods () {
442
- $ this ->mock_upe_payment_gateway ->update_option ( 'upe_enabled_payment_method_ids ' , [ Payment_Method::CARD ] );
352
+ public function test_update_settings_saves_enabled_payment_methods () {
353
+ $ this ->gateway ->update_option ( 'upe_enabled_payment_method_ids ' , [ Payment_Method::CARD ] );
443
354
444
355
$ request = new WP_REST_Request ();
445
356
$ request ->set_param ( 'enabled_payment_method_ids ' , [ Payment_Method::CARD , Payment_Method::GIROPAY ] );
446
357
447
- $ this ->upe_controller ->update_settings ( $ request );
448
-
449
- $ this ->assertEquals ( [ Payment_Method::CARD , Payment_Method::GIROPAY ], $ this ->mock_upe_payment_gateway ->get_option ( 'upe_enabled_payment_method_ids ' ) );
450
- }
451
-
452
- public function test_upe_split_update_settings_saves_enabled_payment_methods () {
453
- $ this ->mock_split_upe_payment_gateway ->update_option ( 'upe_enabled_payment_method_ids ' , [ Payment_Method::CARD ] );
454
-
455
- $ request = new WP_REST_Request ();
456
- $ request ->set_param ( 'enabled_payment_method_ids ' , [ Payment_Method::CARD , Payment_Method::GIROPAY ] );
457
-
458
- $ this ->upe_split_controller ->update_settings ( $ request );
358
+ $ this ->controller ->update_settings ( $ request );
459
359
460
- $ this ->assertEquals ( [ Payment_Method::CARD , Payment_Method::GIROPAY ], $ this ->mock_split_upe_payment_gateway ->get_option ( 'upe_enabled_payment_method_ids ' ) );
360
+ $ this ->assertEquals ( [ Payment_Method::CARD , Payment_Method::GIROPAY ], $ this ->gateway ->get_option ( 'upe_enabled_payment_method_ids ' ) );
461
361
}
462
362
463
363
public function test_update_settings_fails_if_user_cannot_manage_woocommerce () {
@@ -771,7 +671,7 @@ public function deregister_wc_blocks_rest_api() {
771
671
}
772
672
}
773
673
774
- public function test_upe_get_settings_card_eligible_flag (): void {
674
+ public function test_get_settings_card_eligible_flag (): void {
775
675
// Enable Cash on Delivery gateway for the purpose of this test.
776
676
$ cod_gateway = WC ()->payment_gateways ()->payment_gateways ()['cod ' ];
777
677
$ cod_gateway ->enabled = 'yes ' ;
@@ -782,26 +682,7 @@ public function test_upe_get_settings_card_eligible_flag(): void {
782
682
]
783
683
);
784
684
785
- $ response = $ this ->upe_controller ->get_settings ();
786
-
787
- $ this ->assertArrayHasKey ( 'is_card_present_eligible ' , $ response ->get_data () );
788
- $ this ->assertTrue ( $ response ->get_data ()['is_card_present_eligible ' ] );
789
-
790
- // Disable Cash on Delivery gateway.
791
- $ cod_gateway ->enabled = 'no ' ;
792
- }
793
-
794
- public function test_upe_split_get_settings_card_eligible_flag (): void {
795
- // Enable Cash on Delivery gateway for the purpose of this test.
796
- $ cod_gateway = WC ()->payment_gateways ()->payment_gateways ()['cod ' ];
797
- $ cod_gateway ->enabled = 'yes ' ;
798
-
799
- $ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn (
800
- [
801
- 'currency_code ' => 'usd ' ,
802
- ]
803
- );
804
- $ response = $ this ->upe_split_controller ->get_settings ();
685
+ $ response = $ this ->controller ->get_settings ();
805
686
806
687
$ this ->assertArrayHasKey ( 'is_card_present_eligible ' , $ response ->get_data () );
807
688
$ this ->assertTrue ( $ response ->get_data ()['is_card_present_eligible ' ] );
@@ -810,7 +691,7 @@ public function test_upe_split_get_settings_card_eligible_flag(): void {
810
691
$ cod_gateway ->enabled = 'no ' ;
811
692
}
812
693
813
- public function test_upe_get_settings_domestic_currency (): void {
694
+ public function test_get_settings_domestic_currency (): void {
814
695
$ mock_domestic_currency = 'usd ' ;
815
696
$ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn (
816
697
[
@@ -821,49 +702,20 @@ public function test_upe_get_settings_domestic_currency(): void {
821
702
->expects ( $ this ->never () )
822
703
->method ( 'get_account_default_currency ' );
823
704
824
- $ response = $ this ->upe_controller ->get_settings ();
825
-
826
- $ this ->assertArrayHasKey ( 'account_domestic_currency ' , $ response ->get_data () );
827
- $ this ->assertSame ( $ mock_domestic_currency , $ response ->get_data ()['account_domestic_currency ' ] );
828
- }
829
-
830
- public function test_upe_get_settings_domestic_currency_fallbacks_to_default_currency (): void {
831
- $ mock_domestic_currency = 'usd ' ;
832
- $ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn ( [] );
833
- $ this ->mock_wcpay_account
834
- ->expects ( $ this ->once () )
835
- ->method ( 'get_account_default_currency ' )
836
- ->willReturn ( $ mock_domestic_currency );
837
- $ response = $ this ->upe_controller ->get_settings ();
838
-
839
- $ this ->assertArrayHasKey ( 'account_domestic_currency ' , $ response ->get_data () );
840
- $ this ->assertSame ( $ mock_domestic_currency , $ response ->get_data ()['account_domestic_currency ' ] );
841
- }
842
-
843
- public function test_upe_split_get_settings_domestic_currency (): void {
844
- $ mock_domestic_currency = 'usd ' ;
845
- $ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn (
846
- [
847
- 'currency_code ' => $ mock_domestic_currency ,
848
- ]
849
- );
850
- $ this ->mock_wcpay_account
851
- ->expects ( $ this ->never () )
852
- ->method ( 'get_account_default_currency ' );
853
- $ response = $ this ->upe_split_controller ->get_settings ();
705
+ $ response = $ this ->controller ->get_settings ();
854
706
855
707
$ this ->assertArrayHasKey ( 'account_domestic_currency ' , $ response ->get_data () );
856
708
$ this ->assertSame ( $ mock_domestic_currency , $ response ->get_data ()['account_domestic_currency ' ] );
857
709
}
858
710
859
- public function test_upe_split_get_settings_domestic_currency_fallbacks_to_default_currency (): void {
711
+ public function test_get_settings_domestic_currency_fallbacks_to_default_currency (): void {
860
712
$ mock_domestic_currency = 'usd ' ;
861
713
$ this ->mock_localization_service ->method ( 'get_country_locale_data ' )->willReturn ( [] );
862
714
$ this ->mock_wcpay_account
863
715
->expects ( $ this ->once () )
864
716
->method ( 'get_account_default_currency ' )
865
717
->willReturn ( $ mock_domestic_currency );
866
- $ response = $ this ->upe_split_controller ->get_settings ();
718
+ $ response = $ this ->controller ->get_settings ();
867
719
868
720
$ this ->assertArrayHasKey ( 'account_domestic_currency ' , $ response ->get_data () );
869
721
$ this ->assertSame ( $ mock_domestic_currency , $ response ->get_data ()['account_domestic_currency ' ] );
0 commit comments