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 SectionTest extends BaseTest |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Identifier\Section |
||
| 21 | */ |
||
| 22 | private $matcher; |
||
| 23 | |||
| 24 | protected function setUp() |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Returns a Repository mock configured to return the appropriate Section object with given section identifier. |
||
| 32 | * |
||
| 33 | * @param string $sectionIdentifier |
||
| 34 | * |
||
| 35 | * @return \PHPUnit_Framework_MockObject_MockObject |
||
| 36 | */ |
||
| 37 | View Code Duplication | private function generateRepositoryMockForSectionIdentifier($sectionIdentifier) |
|
| 67 | |||
| 68 | /** |
||
| 69 | * @dataProvider matchSectionProvider |
||
| 70 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Identifier\Section::matchLocation |
||
| 71 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
| 72 | * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
||
| 73 | * |
||
| 74 | * @param string|string[] $matchingConfig |
||
| 75 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
| 76 | * @param bool $expectedResult |
||
| 77 | */ |
||
| 78 | public function testMatchLocation($matchingConfig, Repository $repository, $expectedResult) |
||
| 96 | |||
| 97 | public function matchSectionProvider() |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @dataProvider matchSectionProvider |
||
| 125 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Identifier\Section::matchContentInfo |
||
| 126 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
| 127 | * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
||
| 128 | * |
||
| 129 | * @param string|string[] $matchingConfig |
||
| 130 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
| 131 | * @param bool $expectedResult |
||
| 132 | */ |
||
| 133 | View Code Duplication | public function testMatchContentInfo($matchingConfig, Repository $repository, $expectedResult) |
|
| 142 | } |
||
| 143 |