@@ -19,6 +19,18 @@ public function set_up() {
19
19
$ stripe_settings ['test_publishable_key ' ] = 'pk_test_key ' ;
20
20
$ stripe_settings ['test_secret_key ' ] = 'sk_test_key ' ;
21
21
WC_Stripe_Helper::update_main_stripe_settings ( $ stripe_settings );
22
+
23
+ // Add a shipping zone.
24
+ $ zone = new WC_Shipping_Zone ();
25
+ $ zone ->set_zone_name ( 'Worldwide ' );
26
+ $ zone ->set_zone_order ( 1 );
27
+ $ zone ->save ();
28
+
29
+ $ flat_rate_id = $ zone ->add_shipping_method ( 'flat_rate ' );
30
+ $ method = WC_Shipping_Zones::get_shipping_method ( $ flat_rate_id );
31
+ $ option_key = $ method ->get_instance_option_key ();
32
+ $ options ['cost ' ] = '5 ' ;
33
+ update_option ( $ option_key , $ options );
22
34
}
23
35
24
36
/**
@@ -52,17 +64,24 @@ public function test_hides_ece_if_cannot_compute_taxes() {
52
64
WC ()->cart ->add_to_cart ( $ virtual_product ->get_id (), 1 );
53
65
54
66
// Hide if cart has virtual product and tax is based on shipping or billing address.
67
+ update_option ( 'woocommerce_calc_taxes ' , 'yes ' );
55
68
update_option ( 'woocommerce_tax_based_on ' , 'billing ' );
56
69
$ this ->assertFalse ( $ wc_stripe_ece_helper_mock ->should_show_express_checkout_button () );
57
70
58
71
update_option ( 'woocommerce_tax_based_on ' , 'shipping ' );
59
72
$ this ->assertFalse ( $ wc_stripe_ece_helper_mock ->should_show_express_checkout_button () );
60
73
74
+ // Do not hide if taxes are not enabled.
75
+ update_option ( 'woocommerce_calc_taxes ' , 'no ' );
76
+ $ this ->assertTrue ( $ wc_stripe_ece_helper_mock ->should_show_express_checkout_button () );
77
+
61
78
// Do not hide if taxes are not based on customer billing or shipping address.
79
+ update_option ( 'woocommerce_calc_taxes ' , 'yes ' );
62
80
update_option ( 'woocommerce_tax_based_on ' , 'base ' );
63
81
$ this ->assertTrue ( $ wc_stripe_ece_helper_mock ->should_show_express_checkout_button () );
64
82
65
83
// Do not hide if cart requires shipping.
84
+ update_option ( 'woocommerce_tax_based_on ' , 'billing ' );
66
85
$ shippable_product = WC_Helper_Product::create_simple_product ();
67
86
WC ()->cart ->add_to_cart ( $ shippable_product ->get_id (), 1 );
68
87
$ this ->assertTrue ( $ wc_stripe_ece_helper_mock ->should_show_express_checkout_button () );
0 commit comments