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 |
||
14 | class StatusRepositoryTest extends AbstractKernelTestCase |
||
15 | { |
||
16 | /** |
||
17 | * @var StatusRepository |
||
18 | */ |
||
19 | protected $repository; |
||
20 | |||
21 | /** |
||
22 | * Set up the test |
||
23 | */ |
||
24 | public function setUp() |
||
31 | |||
32 | /** |
||
33 | * test find not out of workflow |
||
34 | */ |
||
35 | public function testFindNotOutOfWorkflow() |
||
43 | |||
44 | /** |
||
45 | * test find one by translation state |
||
46 | */ |
||
47 | public function testFindOneByTranslationState() |
||
52 | |||
53 | /** |
||
54 | * test findForPaginate |
||
55 | * |
||
56 | * @param PaginateFinderConfiguration $configuration |
||
57 | * @param int $expectedCount |
||
58 | * @param int $expectedFilteredCount |
||
59 | * |
||
60 | * @dataProvider providePaginateConfiguration |
||
61 | */ |
||
62 | public function testFindForPaginate(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
||
66 | |||
67 | /** |
||
68 | * test count |
||
69 | */ |
||
70 | public function testCountNotOutOfWorkflow() |
||
74 | |||
75 | /** |
||
76 | * test countWithFilter |
||
77 | * |
||
78 | * @param PaginateFinderConfiguration $configuration |
||
79 | * @param int $expectedCount |
||
80 | * @param int $expectedFilteredCount |
||
81 | * |
||
82 | * @dataProvider providePaginateConfiguration |
||
83 | */ |
||
84 | public function testCountWithFilter(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
||
88 | |||
89 | /** |
||
90 | * Provide PaginateFinderConfiguration |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | public function providePaginateConfiguration() |
||
107 | |||
108 | /** |
||
109 | * Test remove statuses |
||
110 | */ |
||
111 | View Code Duplication | public function testRemoveStatuses() |
|
127 | } |
||
128 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.