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 |
||
15 | class ParentLocationTest extends BaseTest |
||
16 | { |
||
17 | /** @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\ParentLocation */ |
||
18 | private $matcher; |
||
19 | |||
20 | protected function setUp(): void |
||
25 | |||
26 | /** |
||
27 | * @dataProvider matchLocationProvider |
||
28 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\ParentLocation::matchLocation |
||
29 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
30 | * |
||
31 | * @param int|int[] $matchingConfig |
||
32 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
33 | * @param bool $expectedResult |
||
34 | */ |
||
35 | public function testMatchLocation($matchingConfig, Location $location, $expectedResult) |
||
40 | |||
41 | public function matchLocationProvider() |
||
66 | |||
67 | /** |
||
68 | * @dataProvider matchContentInfoProvider |
||
69 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\ParentLocation::matchContentInfo |
||
70 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
71 | * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
||
72 | * |
||
73 | * @param int|int[] $matchingConfig |
||
74 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
75 | * @param bool $expectedResult |
||
76 | */ |
||
77 | View Code Duplication | public function testMatchContentInfo($matchingConfig, Repository $repository, $expectedResult) |
|
86 | |||
87 | public function matchContentInfoProvider() |
||
112 | |||
113 | /** |
||
114 | * Returns a Repository mock configured to return the appropriate Location object with given parent location Id. |
||
115 | * |
||
116 | * @param int $parentLocationId |
||
117 | * |
||
118 | * @return \PHPUnit\Framework\MockObject\MockObject |
||
119 | */ |
||
120 | View Code Duplication | private function generateRepositoryMockForParentLocationId($parentLocationId) |
|
144 | } |
||
145 |