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 |
||
19 | class DefaultControllerTest extends RestTestCase |
||
20 | { |
||
21 | /** |
||
22 | * Testing basic functionality |
||
23 | * Api to Weather station, json response |
||
24 | * @return void |
||
25 | */ |
||
26 | public function testIndex() |
||
27 | { |
||
28 | $client = static::createClient(); |
||
29 | |||
30 | // Let's get information from the schema |
||
31 | $client->request('GET', '/proxy/'); |
||
32 | $content = $client->getResponse()->getContent(); |
||
33 | $services = json_decode($content, true); |
||
34 | |||
35 | $this->assertArrayHasKey('weather', $services, ''); |
||
36 | $this->assertArrayHasKey('weather-by-city', $services, ''); |
||
37 | $this->assertArrayHasKey('weather-swiss', $services, ''); |
||
38 | } |
||
39 | /** |
||
40 | * Testing basic functionality |
||
41 | * Api to Weather station, json response |
||
42 | * @return void |
||
43 | */ |
||
44 | View Code Duplication | public function testProxyWithParams() |
|
58 | |||
59 | /** |
||
60 | * Testing basic functionality |
||
61 | * Api to Weather station, limit query params and convert |
||
62 | * @return void |
||
63 | */ |
||
64 | View Code Duplication | public function testProxyQueryParamsLimit() |
|
78 | |||
79 | /** |
||
80 | * Testing basic functionality |
||
81 | * Api to Weather station, limit query params and convert |
||
82 | * @return void |
||
83 | */ |
||
84 | public function testProxyQueryParamsLimitMeteoTest() |
||
108 | } |
||
109 |