Completed
Push — master ( 8bc6ad...b2c48e )
by Vitaliy
16:26 queued 13:19
created

SubscriptionsTest::setUp()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
3
namespace Xsolla\SDK\Tests\Integration\API;
4
5
/**
6
 * @group api
7
 */
8
class SubscriptionsTest extends AbstractAPITest
9
{
10
    protected static $planId;
11
12
    protected static $productId;
13
14
    protected $plan = array(
15
        'name' => array(
16
            'en' => 'Subscription Plan Name',
17
        ),
18
        'group_id' => 'group_id',
19
        'charge' => array(
20
            'amount' => 1,
21
            'currency' => 'USD',
22
            'period' => array(
23
                'value' => 1,
24
                'type' => 'month',
25
            ),
26
        ),
27
        'expiration' => array(
28
            'value' => 3,
29
            'type' => 'month',
30
        ),
31
    );
32
33
    protected $product = array(
34
        'name' => 'Product Name',
35
        'group_id' => 'group_id',
36
    );
37
38
    public function testCreateSubscriptionPlan()
39
    {
40
        $response = static::$xsollaClient->CreateSubscriptionPlan(array(
41
            'project_id' => static::$projectId,
42
            'request' => $this->plan,
43
        ));
44
        static::assertArrayHasKey('plan_id', $response);
45
        static::assertInternalType('integer', $response['plan_id']);
46
        static::$planId = $response['plan_id'];
47
    }
48
49
    /**
50
     * @depends testCreateSubscriptionPlan
51
     */
52
    public function testListSubscriptionPlans()
53
    {
54
        $response = static::$xsollaClient->ListSubscriptionPlans(array(
55
            'project_id' => static::$projectId,
56
        ));
57
        static::assertInternalType('array', $response);
58
    }
59
60
    /**
61
     * @depends testListSubscriptionPlans
62
     */
63
    public function testUpdateSubscriptionPlan()
64
    {
65
        $response = static::$xsollaClient->UpdateSubscriptionPlan(array(
66
            'project_id' => static::$projectId,
67
            'plan_id' => static::$planId,
68
            'request' => $this->plan,
69
        ));
70
        static::assertInternalType('array', $response);
71
    }
72
73
    /**
74
     * @depends testUpdateSubscriptionPlan
75
     */
76
    public function testDisableSubscriptionPlan()
77
    {
78
        static::$xsollaClient->DisableSubscriptionPlan(array(
79
            'project_id' => static::$projectId,
80
            'plan_id' => static::$planId,
81
        ));
82
    }
83
84
    /**
85
     * @depends testDisableSubscriptionPlan
86
     */
87
    public function testEnableSubscriptionPlan()
88
    {
89
        static::$xsollaClient->EnableSubscriptionPlan(array(
90
            'project_id' => static::$projectId,
91
            'plan_id' => static::$planId,
92
        ));
93
    }
94
95
    /**
96
     * @depends testEnableSubscriptionPlan
97
     */
98
    public function testDeleteSubscriptionPlan()
99
    {
100
        static::$xsollaClient->DeleteSubscriptionPlan(array(
101
            'project_id' => static::$projectId,
102
            'plan_id' => static::$planId,
103
        ));
104
    }
105
106
    /**
107
     * @depends testDeleteSubscriptionPlan
108
     */
109 View Code Duplication
    public function testCreateSubscriptionProduct()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
110
    {
111
        $response = static::$xsollaClient->CreateSubscriptionProduct(array(
112
            'project_id' => static::$projectId,
113
            'request' => $this->product,
114
        ));
115
        static::assertArrayHasKey('product_id', $response);
116
        static::$productId = $response['product_id'];
117
    }
118
119
    /**
120
     * @depends testCreateSubscriptionProduct
121
     */
122 View Code Duplication
    public function testUpdateSubscriptionProduct()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
123
    {
124
        $response = static::$xsollaClient->UpdateSubscriptionProduct(array(
125
            'project_id' => static::$projectId,
126
            'product_id' => static::$productId,
127
            'request' => $this->product,
128
        ));
129
        static::assertInternalType('array', $response);
130
    }
131
132
    /**
133
     * @depends testUpdateSubscriptionProduct
134
     */
135
    public function testDeleteSubscriptionProduct()
136
    {
137
        static::$xsollaClient->DeleteSubscriptionProduct(array(
138
            'project_id' => static::$projectId,
139
            'product_id' => static::$productId,
140
        ));
141
    }
142
143
    public function testListSubscriptionProducts()
144
    {
145
        $response = static::$xsollaClient->ListSubscriptionProducts(array(
146
            'project_id' => static::$projectId,
147
        ));
148
        static::assertInternalType('array', $response);
149
    }
150
151
    public function testUpdateSubscription()
152
    {
153
        static::markTestIncomplete('We haven\'t active subscriptions in test project.');
154
    }
155
156 View Code Duplication
    public function testListSubscriptions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
157
    {
158
        $response = static::$xsollaClient->ListSubscriptions(array(
159
            'project_id' => static::$projectId,
160
            'user_id' => static::$userId,
161
        ));
162
        static::assertInternalType('array', $response);
163
    }
164
165 View Code Duplication
    public function testListUserSubscriptionPayments()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
166
    {
167
        $response = static::$xsollaClient->ListUserSubscriptionPayments(array(
168
            'project_id' => static::$projectId,
169
            'user_id' => static::$userId,
170
        ));
171
        static::assertInternalType('array', $response);
172
    }
173
174
    public function testListSubscriptionPayments()
175
    {
176
        $response = static::$xsollaClient->ListSubscriptionPayments(array(
177
            'project_id' => static::$projectId,
178
        ));
179
        static::assertInternalType('array', $response);
180
    }
181
182
    public function testListSubscriptionCurrencies()
183
    {
184
        $response = static::$xsollaClient->ListSubscriptionCurrencies(array(
185
            'project_id' => static::$projectId,
186
        ));
187
        static::assertInternalType('array', $response);
188
    }
189
}
190