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 | |||
| 4 | class AnnotationCest extends CestCase |
||
| 5 | { |
||
| 6 | |||
| 7 | private $annotationBlock = [ |
||
| 8 | 'fields' => [ |
||
| 9 | 'name' => '20:00 - Zahájení srazu', |
||
| 10 | 'description' => '', |
||
| 11 | 'tutor' => 'Tomáš Litera', |
||
| 12 | 'email' => '[email protected]', |
||
| 13 | 'capacity' => '0', |
||
| 14 | ], |
||
| 15 | ]; |
||
| 16 | |||
| 17 | private $annotationProgram = [ |
||
| 18 | 'fields' => [ |
||
| 19 | 'name' => 'Hry a hříčky', |
||
| 20 | 'description' => 'sflvbhflevblf', |
||
| 21 | 'material' => '', |
||
| 22 | 'tutor' => '', |
||
| 23 | 'email' => '[email protected],[email protected]', |
||
| 24 | 'capacity' => '200', |
||
| 25 | ], |
||
| 26 | ]; |
||
| 27 | |||
| 28 | public function _before(AcceptanceTester $I) |
||
| 31 | |||
| 32 | public function _after(AcceptanceTester $I) |
||
| 35 | |||
| 36 | // tests |
||
| 37 | View Code Duplication | public function ensure_that_block_annotation_works(\AcceptanceTester $I) |
|
| 49 | |||
| 50 | View Code Duplication | public function ensure_that_program_annotation_works(\AcceptanceTester $I) |
|
| 62 | |||
| 63 | View Code Duplication | public function block_annotation_should_be_accessible_by_public(\AcceptanceTester $I) |
|
| 71 | |||
| 72 | View Code Duplication | public function program_annotation_should_be_accessible_by_public(\AcceptanceTester $I) |
|
| 80 | |||
| 81 | } |
||
| 82 |