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 = [ |
15
|
|
|
'name' => [ |
16
|
|
|
'en' => 'Subscription Plan Name', |
17
|
|
|
], |
18
|
|
|
'group_id' => 'group_id', |
19
|
|
|
'charge' => [ |
20
|
|
|
'amount' => 1, |
21
|
|
|
'currency' => 'USD', |
22
|
|
|
'period' => [ |
23
|
|
|
'value' => 1, |
24
|
|
|
'type' => 'month', |
25
|
|
|
], |
26
|
|
|
], |
27
|
|
|
'expiration' => [ |
28
|
|
|
'value' => 3, |
29
|
|
|
'type' => 'month', |
30
|
|
|
], |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
protected $product = [ |
34
|
|
|
'name' => 'Product Name', |
35
|
|
|
'group_id' => 'group_id', |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
public function testCreateSubscriptionPlan() |
39
|
|
|
{ |
40
|
|
|
$response = static::$xsollaClient->CreateSubscriptionPlan([ |
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([ |
55
|
|
|
'project_id' => static::$projectId, |
56
|
|
|
'limit' => 100, |
57
|
|
|
]); |
58
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @depends testListSubscriptionPlans |
63
|
|
|
*/ |
64
|
|
|
public function testUpdateSubscriptionPlan() |
65
|
|
|
{ |
66
|
|
|
$response = static::$xsollaClient->UpdateSubscriptionPlan([ |
67
|
|
|
'project_id' => static::$projectId, |
68
|
|
|
'plan_id' => static::$planId, |
69
|
|
|
'request' => $this->plan, |
70
|
|
|
]); |
71
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @depends testUpdateSubscriptionPlan |
76
|
|
|
*/ |
77
|
|
View Code Duplication |
public function testDisableSubscriptionPlan() |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
static::$xsollaClient->DisableSubscriptionPlan([ |
80
|
|
|
'project_id' => static::$projectId, |
81
|
|
|
'plan_id' => static::$planId, |
82
|
|
|
]); |
83
|
|
|
static::assertTrue(true); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @depends testDisableSubscriptionPlan |
88
|
|
|
*/ |
89
|
|
View Code Duplication |
public function testEnableSubscriptionPlan() |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
static::$xsollaClient->EnableSubscriptionPlan([ |
92
|
|
|
'project_id' => static::$projectId, |
93
|
|
|
'plan_id' => static::$planId, |
94
|
|
|
]); |
95
|
|
|
static::assertTrue(true); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @depends testEnableSubscriptionPlan |
100
|
|
|
*/ |
101
|
|
View Code Duplication |
public function testDeleteSubscriptionPlan() |
|
|
|
|
102
|
|
|
{ |
103
|
|
|
static::$xsollaClient->DeleteSubscriptionPlan([ |
104
|
|
|
'project_id' => static::$projectId, |
105
|
|
|
'plan_id' => static::$planId, |
106
|
|
|
]); |
107
|
|
|
static::assertTrue(true); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @depends testDeleteSubscriptionPlan |
112
|
|
|
*/ |
113
|
|
View Code Duplication |
public function testCreateSubscriptionProduct() |
|
|
|
|
114
|
|
|
{ |
115
|
|
|
$response = static::$xsollaClient->CreateSubscriptionProduct([ |
116
|
|
|
'project_id' => static::$projectId, |
117
|
|
|
'request' => $this->product, |
118
|
|
|
]); |
119
|
|
|
static::assertArrayHasKey('product_id', $response); |
120
|
|
|
static::$productId = $response['product_id']; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @depends testCreateSubscriptionProduct |
125
|
|
|
*/ |
126
|
|
|
public function testListSubscriptionPlansWithParams() |
127
|
|
|
{ |
128
|
|
|
$response = static::$xsollaClient->ListSubscriptionPlans([ |
129
|
|
|
'project_id' => static::$projectId, |
130
|
|
|
'limit' => 100, |
131
|
|
|
'offset' => 0, |
132
|
|
|
'product_id' => static::$productId, |
133
|
|
|
'group_id' => $this->product['group_id'], |
134
|
|
|
'external_id' => 12345, |
135
|
|
|
]); |
136
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @depends testCreateSubscriptionProduct |
141
|
|
|
*/ |
142
|
|
View Code Duplication |
public function testUpdateSubscriptionProduct() |
|
|
|
|
143
|
|
|
{ |
144
|
|
|
$response = static::$xsollaClient->UpdateSubscriptionProduct([ |
145
|
|
|
'project_id' => static::$projectId, |
146
|
|
|
'product_id' => static::$productId, |
147
|
|
|
'request' => $this->product, |
148
|
|
|
]); |
149
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @depends testUpdateSubscriptionProduct |
154
|
|
|
*/ |
155
|
|
|
public function testDeleteSubscriptionProduct() |
156
|
|
|
{ |
157
|
|
|
static::$xsollaClient->DeleteSubscriptionProduct([ |
158
|
|
|
'project_id' => static::$projectId, |
159
|
|
|
'product_id' => static::$productId, |
160
|
|
|
]); |
161
|
|
|
static::assertTrue(true); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function testListSubscriptionProducts() |
165
|
|
|
{ |
166
|
|
|
$response = static::$xsollaClient->ListSubscriptionProducts([ |
167
|
|
|
'project_id' => static::$projectId, |
168
|
|
|
]); |
169
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function testListSubscriptionProductsWithParams() |
173
|
|
|
{ |
174
|
|
|
$response = static::$xsollaClient->ListSubscriptionProducts([ |
175
|
|
|
'project_id' => static::$projectId, |
176
|
|
|
'product_id' => static::$productId, |
177
|
|
|
]); |
178
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function testUpdateSubscription() |
182
|
|
|
{ |
183
|
|
|
static::markTestIncomplete('We haven\'t active subscriptions in test project.'); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
View Code Duplication |
public function testListSubscriptions() |
|
|
|
|
187
|
|
|
{ |
188
|
|
|
$response = static::$xsollaClient->ListSubscriptions([ |
189
|
|
|
'project_id' => static::$projectId, |
190
|
|
|
'user_id' => static::$userId, |
191
|
|
|
]); |
192
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function testListSubscriptionWithParams() |
196
|
|
|
{ |
197
|
|
|
$response = static::$xsollaClient->ListSubscriptions([ |
198
|
|
|
'project_id' => static::$projectId, |
199
|
|
|
'user_id' => static::$userId, |
200
|
|
|
'plan_id' => static::$planId, |
201
|
|
|
'product_id' => static::$productId, |
202
|
|
|
]); |
203
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
204
|
|
|
} |
205
|
|
|
|
206
|
|
View Code Duplication |
public function testListUserSubscriptionPayments() |
|
|
|
|
207
|
|
|
{ |
208
|
|
|
$response = static::$xsollaClient->ListUserSubscriptionPayments([ |
209
|
|
|
'project_id' => static::$projectId, |
210
|
|
|
'user_id' => static::$userId, |
211
|
|
|
]); |
212
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
public function testListSubscriptionPayments() |
216
|
|
|
{ |
217
|
|
|
$response = static::$xsollaClient->ListSubscriptionPayments([ |
218
|
|
|
'project_id' => static::$projectId, |
219
|
|
|
]); |
220
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public function testListSubscriptionCurrencies() |
224
|
|
|
{ |
225
|
|
|
$response = static::$xsollaClient->ListSubscriptionCurrencies([ |
226
|
|
|
'project_id' => static::$projectId, |
227
|
|
|
]); |
228
|
|
|
static::assertInternalType('array', $response); |
|
|
|
|
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.