Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 100 % |
Changes | 0 |
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 GeoTest extends UnitTestCase |
||
9 | { |
||
10 | public function testInstantiation() |
||
11 | { |
||
12 | $this->assertInstanceOf('Lyal\Checkr\Entities\Resources\Geo', $this->getGeo()); |
||
13 | } |
||
14 | |||
15 | public function testSetId() |
||
16 | { |
||
17 | $geo = $this->getGeo(); |
||
18 | $geo->id = 'e44aa283528e6fde7d542194'; |
||
19 | $this->assertSame('e44aa283528e6fde7d542194', $geo->id); |
||
20 | } |
||
21 | |||
22 | public function testFields() |
||
23 | { |
||
24 | $values = [ |
||
25 | 'id' => 'e44aa283528e6fde7d542194', |
||
26 | 'object' => 'geo', |
||
27 | 'uri' => '/v1/geos/e44aa283528e6fde7d542194', |
||
28 | 'created_at' => '2015-01-18T12:34:00Z', |
||
29 | 'name' => 'San Francisco', |
||
30 | 'state' => 'CA', |
||
31 | 'deleted_at' => NULL, |
||
32 | ]; |
||
33 | |||
34 | $geo = $this->getGeo($values); |
||
35 | |||
36 | foreach ($values as $key => $value) { |
||
37 | $this->assertEquals($value, $geo->{$key}); |
||
38 | } |
||
39 | |||
40 | } |
||
41 | |||
42 | protected function getGeo($values = NULL) |
||
43 | { |
||
44 | return new Geo($values,$this->getClient()); |
||
45 | } |
||
46 | } |