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 DepthTest extends BaseTest |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Depth |
||
| 22 | */ |
||
| 23 | private $matcher; |
||
| 24 | |||
| 25 | protected function setUp() |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @dataProvider matchLocationProvider |
||
| 33 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Depth::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() |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @dataProvider matchContentInfoProvider |
||
| 84 | * @covers eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Depth::matchContentInfo |
||
| 85 | * @covers eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
| 86 | * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
||
| 87 | * |
||
| 88 | * @param int|int[] $matchingConfig |
||
| 89 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
| 90 | * @param bool $expectedResult |
||
| 91 | */ |
||
| 92 | View Code Duplication | public function testMatchContentInfo($matchingConfig, Repository $repository, $expectedResult) |
|
| 101 | |||
| 102 | public function matchContentInfoProvider() |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Returns a Repository mock configured to return the appropriate Location object with given parent location Id. |
||
| 130 | * |
||
| 131 | * @param int $depth |
||
| 132 | * |
||
| 133 | * @return \PHPUnit_Framework_MockObject_MockObject |
||
| 134 | */ |
||
| 135 | private function generateRepositoryMockForDepth($depth) |
||
| 158 | } |
||
| 159 |