5
5
* @package WooCommerce\Payments\Tests
6
6
*/
7
7
8
+ use PHPUnit \Framework \MockObject \MockObject ;
9
+ use WCPay \Database_Cache ;
10
+
8
11
/**
9
12
* WC_Payments_Features unit tests.
10
13
*/
11
14
class WC_Payments_Features_Test extends WCPAY_UnitTestCase {
12
15
16
+ /**
17
+ * @var Database_Cache|MockObject
18
+ */
19
+ protected $ mock_cache ;
20
+
13
21
const FLAG_OPTION_NAME_TO_FRONTEND_KEY_MAPPING = [
14
22
'_wcpay_feature_upe ' => 'upe ' ,
15
23
'_wcpay_feature_upe_settings_preview ' => 'upeSettingsPreview ' ,
@@ -18,6 +26,7 @@ class WC_Payments_Features_Test extends WCPAY_UnitTestCase {
18
26
'_wcpay_feature_account_overview_task_list ' => 'accountOverviewTaskList ' ,
19
27
'_wcpay_feature_custom_deposit_schedules ' => 'customDepositSchedules ' ,
20
28
'_wcpay_feature_auth_and_capture ' => 'isAuthAndCaptureEnabled ' ,
29
+ '_wcpay_feature_progressive_onboarding ' => 'progressiveOnboarding ' ,
21
30
];
22
31
23
32
public function set_up () {
@@ -149,7 +158,7 @@ function ( $pre_option, $option, $default ) {
149
158
150
159
public function test_is_woopay_express_checkout_enabled_returns_false_when_platform_checkout_eligible_is_false () {
151
160
add_filter (
152
- 'pre_option__wcpay_feature_woopay_express_checkout ' ,
161
+ 'pre_option__ ' . WC_Payments_Features:: PROGRESSIVE_ONBOARDING_FLAG_NAME ,
153
162
function ( $ pre_option , $ option , $ default ) {
154
163
return '1 ' ;
155
164
},
@@ -160,6 +169,35 @@ function ( $pre_option, $option, $default ) {
160
169
$ this ->assertFalse ( WC_Payments_Features::is_woopay_express_checkout_enabled () );
161
170
}
162
171
172
+ public function test_is_progressive_onboarding_enabled_returns_true () {
173
+ add_filter (
174
+ 'pre_option_ ' . WC_Payments_Features::PROGRESSIVE_ONBOARDING_FLAG_NAME ,
175
+ function ( $ pre_option , $ option , $ default ) {
176
+ return '1 ' ;
177
+ },
178
+ 10 ,
179
+ 3
180
+ );
181
+ $ this ->assertTrue ( WC_Payments_Features::is_progressive_onboarding_enabled () );
182
+ }
183
+
184
+ public function test_is_progressive_onboarding_enabled_returns_false_when_flag_is_false () {
185
+ add_filter (
186
+ 'pre_option_ ' . WC_Payments_Features::PROGRESSIVE_ONBOARDING_FLAG_NAME ,
187
+ function ( $ pre_option , $ option , $ default ) {
188
+ return '0 ' ;
189
+ },
190
+ 10 ,
191
+ 3
192
+ );
193
+ $ this ->assertFalse ( WC_Payments_Features::is_progressive_onboarding_enabled () );
194
+ $ this ->assertArrayNotHasKey ( 'progressiveOnboarding ' , WC_Payments_Features::to_array () );
195
+ }
196
+
197
+ public function test_is_progressive_onboarding_enabled_returns_false_when_flag_is_not_set () {
198
+ $ this ->assertFalse ( WC_Payments_Features::is_progressive_onboarding_enabled () );
199
+ }
200
+
163
201
private function setup_enabled_flags ( array $ enabled_flags ) {
164
202
foreach ( array_keys ( self ::FLAG_OPTION_NAME_TO_FRONTEND_KEY_MAPPING ) as $ flag ) {
165
203
add_filter (
0 commit comments