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 |
||
18 | class ParentLocationTest extends BaseTest |
||
19 | { |
||
20 | /** |
||
21 | * @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\ParentLocation |
||
22 | */ |
||
23 | private $matcher; |
||
24 | |||
25 | protected function setUp() |
||
30 | |||
31 | /** |
||
32 | * @dataProvider matchLocationProvider |
||
33 | * @covers eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\ParentLocation::matchLocation |
||
34 | * @covers eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
35 | * |
||
36 | * @param int|int[] $matchingConfig |
||
37 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
38 | * @param bool $expectedResult |
||
39 | */ |
||
40 | public function testMatchLocation($matchingConfig, Location $location, $expectedResult) |
||
45 | |||
46 | public function matchLocationProvider() |
||
71 | |||
72 | /** |
||
73 | * @dataProvider matchContentInfoProvider |
||
74 | * @covers eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\ParentLocation::matchContentInfo |
||
75 | * @covers eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
76 | * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
||
77 | * |
||
78 | * @param int|int[] $matchingConfig |
||
79 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
80 | * @param bool $expectedResult |
||
81 | */ |
||
82 | View Code Duplication | public function testMatchContentInfo($matchingConfig, Repository $repository, $expectedResult) |
|
91 | |||
92 | public function matchContentInfoProvider() |
||
117 | |||
118 | /** |
||
119 | * Returns a Repository mock configured to return the appropriate Location object with given parent location Id. |
||
120 | * |
||
121 | * @param int $parentLocationId |
||
122 | * |
||
123 | * @return \PHPUnit_Framework_MockObject_MockObject |
||
124 | */ |
||
125 | View Code Duplication | private function generateRepositoryMockForParentLocationId($parentLocationId) |
|
152 | } |
||
153 |