These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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() |
|
0 ignored issues
–
show
|
|||
78 | { |
||
79 | $response = static::$xsollaClient->DisableSubscriptionPlan([ |
||
0 ignored issues
–
show
Are you sure the assignment to
$response is correct as static::$xsollaClient->D...d' => static::$planId)) (which targets Xsolla\SDK\API\XsollaCli...sableSubscriptionPlan() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
Loading history...
|
|||
80 | 'project_id' => static::$projectId, |
||
81 | 'plan_id' => static::$planId, |
||
82 | ]); |
||
83 | static::assertSame(204, $response->getStatusCode()); |
||
0 ignored issues
–
show
|
|||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @depends testDisableSubscriptionPlan |
||
88 | */ |
||
89 | View Code Duplication | public function testEnableSubscriptionPlan() |
|
0 ignored issues
–
show
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...
|
|||
90 | { |
||
91 | $response = static::$xsollaClient->EnableSubscriptionPlan([ |
||
0 ignored issues
–
show
Are you sure the assignment to
$response is correct as static::$xsollaClient->E...d' => static::$planId)) (which targets Xsolla\SDK\API\XsollaCli...nableSubscriptionPlan() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
Loading history...
|
|||
92 | 'project_id' => static::$projectId, |
||
93 | 'plan_id' => static::$planId, |
||
94 | ]); |
||
95 | static::assertSame(204, $response->getStatusCode()); |
||
0 ignored issues
–
show
|
|||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @depends testEnableSubscriptionPlan |
||
100 | */ |
||
101 | View Code Duplication | public function testDeleteSubscriptionPlan() |
|
0 ignored issues
–
show
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...
|
|||
102 | { |
||
103 | $response = static::$xsollaClient->DeleteSubscriptionPlan([ |
||
0 ignored issues
–
show
Are you sure the assignment to
$response is correct as static::$xsollaClient->D...d' => static::$planId)) (which targets Xsolla\SDK\API\XsollaCli...eleteSubscriptionPlan() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
Loading history...
|
|||
104 | 'project_id' => static::$projectId, |
||
105 | 'plan_id' => static::$planId, |
||
106 | ]); |
||
107 | static::assertSame(204, $response->getStatusCode()); |
||
0 ignored issues
–
show
|
|||
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 | $response = static::$xsollaClient->DeleteSubscriptionProduct([ |
||
0 ignored issues
–
show
Are you sure the assignment to
$response is correct as static::$xsollaClient->D...=> static::$productId)) (which targets Xsolla\SDK\API\XsollaCli...teSubscriptionProduct() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
Loading history...
|
|||
158 | 'project_id' => static::$projectId, |
||
159 | 'product_id' => static::$productId, |
||
160 | ]); |
||
161 | static::assertSame(204, $response->getStatusCode()); |
||
0 ignored issues
–
show
|
|||
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 |
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.