Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
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() |
||
48 | |||
49 | /** |
||
50 | * @depends testCreateSubscriptionPlan |
||
51 | */ |
||
52 | public function testListSubscriptionPlans() |
||
60 | |||
61 | /** |
||
62 | * @depends testListSubscriptionPlans |
||
63 | */ |
||
64 | public function testUpdateSubscriptionPlan() |
||
73 | |||
74 | /** |
||
75 | * @depends testUpdateSubscriptionPlan |
||
76 | */ |
||
77 | View Code Duplication | public function testDisableSubscriptionPlan() |
|
85 | |||
86 | /** |
||
87 | * @depends testDisableSubscriptionPlan |
||
88 | */ |
||
89 | View Code Duplication | public function testEnableSubscriptionPlan() |
|
97 | |||
98 | /** |
||
99 | * @depends testEnableSubscriptionPlan |
||
100 | */ |
||
101 | View Code Duplication | public function testDeleteSubscriptionPlan() |
|
109 | |||
110 | /** |
||
111 | * @depends testDeleteSubscriptionPlan |
||
112 | */ |
||
113 | View Code Duplication | public function testCreateSubscriptionProduct() |
|
122 | |||
123 | /** |
||
124 | * @depends testCreateSubscriptionProduct |
||
125 | */ |
||
126 | public function testListSubscriptionPlansWithParams() |
||
138 | |||
139 | /** |
||
140 | * @depends testCreateSubscriptionProduct |
||
141 | */ |
||
142 | View Code Duplication | public function testUpdateSubscriptionProduct() |
|
151 | |||
152 | /** |
||
153 | * @depends testUpdateSubscriptionProduct |
||
154 | */ |
||
155 | public function testDeleteSubscriptionProduct() |
||
163 | |||
164 | public function testListSubscriptionProducts() |
||
171 | |||
172 | public function testListSubscriptionProductsWithParams() |
||
180 | |||
181 | public function testUpdateSubscription() |
||
185 | |||
186 | View Code Duplication | public function testListSubscriptions() |
|
194 | |||
195 | public function testListSubscriptionWithParams() |
||
205 | |||
206 | View Code Duplication | public function testListUserSubscriptionPayments() |
|
214 | |||
215 | public function testListSubscriptionPayments() |
||
222 | |||
223 | public function testListSubscriptionCurrencies() |
||
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.