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 VirtualItemsTest extends AbstractAPITest |
||
9 | { |
||
10 | protected static $virtualItemSku; |
||
11 | |||
12 | protected static $virtualItemId; |
||
13 | |||
14 | protected static $virtualItemsGroupId; |
||
15 | |||
16 | protected static $virtualItem; |
||
17 | |||
18 | protected $virtualItemsGroup = [ |
||
19 | 'name' => [ |
||
20 | 'en' => 'Virtual Item Group', |
||
21 | ], |
||
22 | 'description' => [ |
||
23 | 'en' => 'Virtual Item Group Description', |
||
24 | ], |
||
25 | 'enabled' => true, |
||
26 | ]; |
||
27 | |||
28 | public function setUp() |
||
36 | |||
37 | public function testListVirtualItemsGroups() |
||
44 | |||
45 | public function testListVirtualItems() |
||
52 | |||
53 | View Code Duplication | public function testListVirtualItemsWithParams() |
|
63 | |||
64 | View Code Duplication | public function testCreateVirtualItemsGroup() |
|
74 | |||
75 | /** |
||
76 | * @depends testCreateVirtualItemsGroup |
||
77 | */ |
||
78 | public function testGetVirtualItemsGroup() |
||
86 | |||
87 | /** |
||
88 | * @depends testGetVirtualItemsGroup |
||
89 | */ |
||
90 | public function testUpdateVirtualItemsGroup() |
||
91 | { |
||
92 | static::$xsollaClient->UpdateVirtualItemsGroup([ |
||
93 | 'project_id' => static::$projectId, |
||
94 | 'group_id' => static::$virtualItemsGroupId, |
||
95 | 'request' => $this->virtualItemsGroup, |
||
96 | ]); |
||
97 | static::assertTrue(true); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @depends testUpdateVirtualItemsGroup |
||
102 | */ |
||
103 | View Code Duplication | public function testCreateVirtualItem() |
|
112 | |||
113 | /** |
||
114 | * @depends testCreateVirtualItem |
||
115 | */ |
||
116 | public function testGetVirtualItem() |
||
124 | |||
125 | /** |
||
126 | * @depends testGetVirtualItem |
||
127 | */ |
||
128 | public function testUpdateVirtualItem() |
||
129 | { |
||
130 | static::$xsollaClient->UpdateVirtualItem([ |
||
131 | 'project_id' => static::$projectId, |
||
132 | 'item_id' => static::$virtualItemId, |
||
133 | 'request' => static::$virtualItem, |
||
134 | ]); |
||
135 | static::assertTrue(true); |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * @depends testUpdateVirtualItemsGroup |
||
140 | */ |
||
141 | View Code Duplication | public function testUpdateVirtualItemOrderInGroup() |
|
142 | { |
||
143 | static::$xsollaClient->UpdateVirtualItemOrderInGroup([ |
||
144 | 'project_id' => static::$projectId, |
||
145 | 'request' => [ |
||
146 | 'group_id' => static::$virtualItemsGroupId, |
||
147 | 'virtual_items' => [static::$virtualItemSku], |
||
148 | ], |
||
149 | ]); |
||
150 | static::assertTrue(true); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @depends testUpdateVirtualItemOrderInGroup |
||
155 | */ |
||
156 | public function testDeleteVirtualItem() |
||
157 | { |
||
158 | static::$xsollaClient->DeleteVirtualItem([ |
||
159 | 'project_id' => static::$projectId, |
||
160 | 'item_id' => static::$virtualItemId, |
||
161 | ]); |
||
162 | static::assertTrue(true); |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * @depends testDeleteVirtualItem |
||
167 | */ |
||
168 | public function testDeleteVirtualItemsGroup() |
||
176 | } |
||
177 |
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.