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 |
||
10 | class Test_Abtest extends TestCase { |
||
11 | /** |
||
12 | * Test setup. |
||
13 | */ |
||
14 | public function setUp() { |
||
28 | |||
29 | /** |
||
30 | * Test teardown. |
||
31 | */ |
||
32 | public function tearDown() { |
||
35 | |||
36 | /** |
||
37 | * @covers Automattic\Jetpack\Abtest::get_variation |
||
38 | */ |
||
39 | public function test_with_no_test_name_provided() { |
||
43 | |||
44 | /** |
||
45 | * @covers Automattic\Jetpack\Abtest::get_variation |
||
46 | */ |
||
47 | public function test_with_incorrect_test_name_provided() { |
||
51 | |||
52 | /** |
||
53 | * @covers Automattic\Jetpack\Abtest::get_variation |
||
54 | */ |
||
55 | public function test_when_test_inactive_or_does_not_exist() { |
||
68 | |||
69 | /** |
||
70 | * @covers Automattic\Jetpack\Abtest::get_variation |
||
71 | */ |
||
72 | View Code Duplication | public function test_when_error_or_malformed_response() { |
|
82 | |||
83 | /** |
||
84 | * @covers Automattic\Jetpack\Abtest::get_variation |
||
85 | */ |
||
86 | View Code Duplication | public function test_when_response_in_unexpected_format() { |
|
98 | |||
99 | /** |
||
100 | * @covers Automattic\Jetpack\Abtest::get_variation |
||
101 | */ |
||
102 | public function test_with_valid_active_test() { |
||
119 | } |
||
120 | |||
127 |