1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Subscriptions helpers. |
4
|
|
|
* |
5
|
|
|
* @package WooCommerce\Payments\Tests |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
// Set up subscriptions mocks. |
9
|
|
|
function wcs_order_contains_subscription( $order ) { |
10
|
|
|
if ( ! WC_Subscriptions::$wcs_order_contains_subscription ) { |
11
|
|
|
return; |
12
|
|
|
} |
13
|
|
|
return call_user_func( WC_Subscriptions::$wcs_order_contains_subscription, $order ); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
function wcs_get_subscriptions_for_order( $order ) { |
17
|
|
|
if ( ! WC_Subscriptions::$wcs_get_subscriptions_for_order ) { |
18
|
|
|
return; |
19
|
|
|
} |
20
|
|
|
return call_user_func( WC_Subscriptions::$wcs_get_subscriptions_for_order, $order ); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
function wcs_is_subscription( $order ) { |
24
|
|
|
if ( ! WC_Subscriptions::$wcs_is_subscription ) { |
25
|
|
|
return; |
26
|
|
|
} |
27
|
|
|
return call_user_func( WC_Subscriptions::$wcs_is_subscription, $order ); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function wcs_get_subscription( $subscription ) { |
31
|
|
|
if ( ! WC_Subscriptions::$wcs_get_subscription ) { |
32
|
|
|
return; |
33
|
|
|
} |
34
|
|
|
return call_user_func( WC_Subscriptions::$wcs_get_subscription, $subscription ); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Class WC_Subscriptions. |
39
|
|
|
* |
40
|
|
|
* This helper class should ONLY be used for unit tests!. |
41
|
|
|
*/ |
42
|
|
|
class WC_Subscriptions { |
43
|
|
|
/** |
44
|
|
|
* Subscriptions version, defaults to 3.0.7 |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
public static $version = '3.0.7'; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* wcs_order_contains_subscription mock. |
52
|
|
|
* |
53
|
|
|
* @var function |
54
|
|
|
*/ |
55
|
|
|
public static $wcs_order_contains_subscription = null; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* wcs_get_subscriptions_for_order mock. |
59
|
|
|
* |
60
|
|
|
* @var function |
61
|
|
|
*/ |
62
|
|
|
public static $wcs_get_subscriptions_for_order = null; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* wcs_is_subscription mock. |
66
|
|
|
* |
67
|
|
|
* @var function |
68
|
|
|
*/ |
69
|
|
|
public static $wcs_is_subscription = null; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* wcs_get_subscription mock. |
73
|
|
|
* |
74
|
|
|
* @var function |
75
|
|
|
*/ |
76
|
|
|
public static $wcs_get_subscription = null; |
77
|
|
|
|
78
|
|
|
public static function set_wcs_order_contains_subscription( $function ) { |
79
|
|
|
self::$wcs_order_contains_subscription = $function; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public static function set_wcs_get_subscriptions_for_order( $function ) { |
83
|
|
|
self::$wcs_get_subscriptions_for_order = $function; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public static function set_wcs_is_subscription( $function ) { |
87
|
|
|
self::$wcs_is_subscription = $function; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public static function set_wcs_get_subscription( $function ) { |
91
|
|
|
self::$wcs_get_subscription = $function; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|