Passed
Push — master ( c1a9cf...81fe5a )
by Matthew
04:50
created

TestStripe::updateSubscription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 2
dl 0
loc 1
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MySociety\TheyWorkForYou;
4
5
class TestStripe extends Stripe {
6 1
    public function getSubscription($args) {
7 1
        if ($args['id'] == 'sub_123') {
8 1
            return \Stripe\Util\Util::convertToStripeObject([
9 1
                'id' => 'sub_123',
10
                'discount' => [
11
                    'coupon' => ['percent_off' => 100],
12
                    'end' => null,
13
                ],
14
                'schedule' => null,
15
                'plan' => [
16
                    'amount' => '2000',
17
                    'id' => 'twfy-1k',
18
                    'nickname' => 'Some calls per month',
19
                    'interval' => 'month',
20
                ],
21 1
                'cancel_at_period_end' => false,
22 1
                'created' => time(),
23
                'current_period_end' => time(),
24
                'latest_invoice' => [],
25
                'customer' => [
26
                    'id' => 'cus_123',
27
                    'balance' => 0,
28
                    'default_source' => [],
29
                    'invoice_settings' => [
30
                        'default_payment_method' => [],
31
                    ],
32 1
                ],
33
            ], null);
34
        } elseif ($args['id'] == 'sub_456') {
35
            return \Stripe\Util\Util::convertToStripeObject([
36
                'id' => 'sub_456',
37 1
                'discount' => null,
38 1
                'schedule' => [
39
                    'id' => 'sub_sched',
40
                    'phases' => [
41
                    ],
42
                ],
43
                'plan' => [
44
                    'amount' => '4167',
45
                    'id' => 'twfy-5k',
46
                    'nickname' => 'Many calls per month',
47
                    'interval' => 'month',
48 1
                ],
49 1
                'cancel_at_period_end' => false,
50
                'created' => time(),
51
                'current_period_end' => time(),
52
                'latest_invoice' => [],
53
                'customer' => [
54
                    'id' => 'cus_456',
55
                    'balance' => 0,
56
                    'default_source' => [],
57
                    'invoice_settings' => [
58
                        'default_payment_method' => [],
59
                    ],
60
                ],
61
            ], null);
62
        }
63
        return \Stripe\Util\Util::convertToStripeObject([], null);
64
    }
65
66
    public function getUpcomingInvoice($args) {
67
        return \Stripe\Util\Util::convertToStripeObject([], null);
68
    }
69
70
    public function createCustomer($args) {
71
        return \Stripe\Util\Util::convertToStripeObject([
72
            'id' => 'cus_123',
73
            'email' => '[email protected]',
74
        ], null);
75
    }
76
77
    public function updateCustomer($id, $args) {
78
        return \Stripe\Util\Util::convertToStripeObject([], null);
79
    }
80
81
    public function createSubscription($args) {
82
        if ($args['plan'] == 'twfy-5k') {
83
            $id = 'sub_456';
84
        } else {
85
            $id = 'sub_123';
86
        }
87
        return \Stripe\Util\Util::convertToStripeObject([
88
            'id' => $id,
89
        ], null);
90
    }
91
92
    public function createSchedule($id) {
93
        return \Stripe\Util\Util::convertToStripeObject([
94
            'id' => 'schedule_1',
95
            'phases' => [
96
                [
97
                    'start_date' => time(),
98
                    'end_date' => time(),
99
                    'discounts' => null,
100
                    'items' => [
101
                        [
102
                            'price' => '5000',
103
                        ],
104
                    ]
105
                ],
106
            ],
107
        ], null);
108
    }
109
110
    public function updateSchedule($id, $phases) {
111
    }
112
113
    public function releaseSchedule($id) {
114
    }
115
116
    public function updateSubscription($id, $args) {
117
    }
118
}
119