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 UrlAliasTest extends BaseTest |
||
| 16 | { |
||
| 17 | /** @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias */ |
||
| 18 | private $matcher; |
||
| 19 | |||
| 20 | protected function setUp(): void |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @dataProvider setMatchingConfigProvider |
||
| 28 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::setMatchingConfig |
||
| 29 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
| 30 | * |
||
| 31 | * @param string $matchingConfig |
||
| 32 | * @param string[] $expectedValues |
||
| 33 | */ |
||
| 34 | public function testSetMatchingConfig($matchingConfig, $expectedValues) |
||
| 42 | |||
| 43 | View Code Duplication | public function setMatchingConfigProvider() |
|
| 53 | |||
| 54 | /** |
||
| 55 | * Returns a Repository mock configured to return the appropriate Section object with given section identifier. |
||
| 56 | * |
||
| 57 | * @param string $path |
||
| 58 | * |
||
| 59 | * @return \PHPUnit\Framework\MockObject\MockObject |
||
| 60 | */ |
||
| 61 | private function generateRepositoryMockForUrlAlias($path) |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @dataProvider matchLocationProvider |
||
| 100 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::matchLocation |
||
| 101 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::setMatchingConfig |
||
| 102 | * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
||
| 103 | * |
||
| 104 | * @param string|string[] $matchingConfig |
||
| 105 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
| 106 | * @param bool $expectedResult |
||
| 107 | */ |
||
| 108 | View Code Duplication | public function testMatchLocation($matchingConfig, Repository $repository, $expectedResult) |
|
| 117 | |||
| 118 | public function matchLocationProvider() |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::matchContentInfo |
||
| 151 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::setMatchingConfig |
||
| 152 | */ |
||
| 153 | public function testMatchContentInfo() |
||
| 160 | } |
||
| 161 |