@@ -25,15 +25,20 @@ public function test_constants_defined() {
25
25
}
26
26
27
27
/**
28
- * Tests for `maybe_deactivate_payment_methods `.
28
+ * Tests for `maybe_toggle_payment_methods `.
29
29
*
30
+ * @param array $active_gateways The active payment gateways.
31
+ * @param array $enabled_payment_method_ids The enabled payment method IDs.
32
+ * @param bool $oc_enabled Whether the one-click payment methods are enabled.
33
+ * @param int $update_enable_payment_methods_calls The number of times `update_enabled_payment_methods` should be called.
30
34
* @return void
31
35
*
32
- * @dataProvider provide_test_maybe_deactivate_payment_methods
36
+ * @dataProvider provide_test_maybe_toggle_payment_methods
33
37
*/
34
- public function test_maybe_deactivate_payment_methods (
38
+ public function test_maybe_toggle_payment_methods (
35
39
$ active_gateways ,
36
40
$ enabled_payment_method_ids ,
41
+ $ oc_enabled ,
37
42
$ update_enable_payment_methods_calls
38
43
) {
39
44
$ original_payment_gateways = WC ()->payment_gateways ->payment_gateways ;
@@ -45,6 +50,10 @@ public function test_maybe_deactivate_payment_methods(
45
50
->disableOriginalConstructor ()
46
51
->getMock ();
47
52
53
+ $ upe_payment_gateway ->expects ( $ this ->once () )
54
+ ->method ( 'is_oc_enabled ' )
55
+ ->willReturn ( $ oc_enabled );
56
+
48
57
$ upe_payment_gateway ->expects ( $ this ->once () )
49
58
->method ( 'get_upe_enabled_payment_method_ids ' )
50
59
->willReturn ( $ enabled_payment_method_ids );
@@ -61,7 +70,7 @@ public function test_maybe_deactivate_payment_methods(
61
70
$ wc_stripe ->method ( 'get_main_stripe_gateway ' )
62
71
->willReturn ( $ upe_payment_gateway );
63
72
64
- $ wc_stripe ->maybe_deactivate_payment_methods ();
73
+ $ wc_stripe ->maybe_toggle_payment_methods ();
65
74
66
75
// Clean up.
67
76
WC ()->payment_gateways ->payment_gateways = $ original_payment_gateways ;
@@ -72,13 +81,14 @@ public function test_maybe_deactivate_payment_methods(
72
81
*
73
82
* @return array
74
83
*/
75
- public function provide_test_maybe_deactivate_payment_methods () {
84
+ public function provide_test_maybe_toggle_payment_methods () {
76
85
return [
77
86
'none active ' => [
78
87
'active gateways ' => [],
79
88
'enabled payment method IDs ' => [
80
89
WC_Stripe_Payment_Methods::CARD ,
81
90
],
91
+ 'OC enabled ' => false ,
82
92
'update enable payment methods calls ' => 0 ,
83
93
],
84
94
'affirm ' => [
@@ -92,6 +102,7 @@ public function provide_test_maybe_deactivate_payment_methods() {
92
102
WC_Stripe_Payment_Methods::CARD ,
93
103
WC_Stripe_Payment_Methods::AFFIRM ,
94
104
],
105
+ 'OC enabled ' => false ,
95
106
'update enable payment methods calls ' => 1 ,
96
107
],
97
108
'klarna ' => [
@@ -105,6 +116,7 @@ public function provide_test_maybe_deactivate_payment_methods() {
105
116
WC_Stripe_Payment_Methods::CARD ,
106
117
WC_Stripe_Payment_Methods::KLARNA ,
107
118
],
119
+ 'OC enabled ' => false ,
108
120
'update enable payment methods calls ' => 1 ,
109
121
],
110
122
'klarna and affirm active, but not on Stripe ' => [
@@ -121,6 +133,7 @@ public function provide_test_maybe_deactivate_payment_methods() {
121
133
'enabled payment method IDs ' => [
122
134
WC_Stripe_Payment_Methods::CARD ,
123
135
],
136
+ 'OC enabled ' => false ,
124
137
'update enable payment methods calls ' => 0 ,
125
138
],
126
139
'klarna and affirm active in both ' => [
@@ -139,6 +152,7 @@ public function provide_test_maybe_deactivate_payment_methods() {
139
152
WC_Stripe_Payment_Methods::AFFIRM ,
140
153
WC_Stripe_Payment_Methods::KLARNA ,
141
154
],
155
+ 'OC enabled ' => false ,
142
156
'update enable payment methods calls ' => 1 ,
143
157
],
144
158
'amazon pay ' => [
@@ -147,6 +161,13 @@ public function provide_test_maybe_deactivate_payment_methods() {
147
161
WC_Stripe_Payment_Methods::CARD ,
148
162
WC_Stripe_Payment_Methods::AMAZON_PAY ,
149
163
],
164
+ 'OC enabled ' => false ,
165
+ 'update enable payment methods calls ' => 1 ,
166
+ ],
167
+ 'card, OC enabled ' => [
168
+ 'active gateways ' => [],
169
+ 'enabled payment method IDs ' => [],
170
+ 'OC enabled ' => true ,
150
171
'update enable payment methods calls ' => 1 ,
151
172
],
152
173
];
0 commit comments