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