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 UrlAliasTest extends BaseTest |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias |
||
| 21 | */ |
||
| 22 | private $matcher; |
||
| 23 | |||
| 24 | protected function setUp() |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @dataProvider setMatchingConfigProvider |
||
| 32 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::setMatchingConfig |
||
| 33 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
||
| 34 | * |
||
| 35 | * @param string $matchingConfig |
||
| 36 | * @param string[] $expectedValues |
||
| 37 | */ |
||
| 38 | public function testSetMatchingConfig($matchingConfig, $expectedValues) |
||
| 46 | |||
| 47 | View Code Duplication | public function setMatchingConfigProvider() |
|
| 57 | |||
| 58 | /** |
||
| 59 | * Returns a Repository mock configured to return the appropriate Section object with given section identifier. |
||
| 60 | * |
||
| 61 | * @param string $path |
||
| 62 | * |
||
| 63 | * @return \PHPUnit_Framework_MockObject_MockObject |
||
| 64 | */ |
||
| 65 | private function generateRepositoryMockForUrlAlias($path) |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @dataProvider matchLocationProvider |
||
| 104 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::matchLocation |
||
| 105 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::setMatchingConfig |
||
| 106 | * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
||
| 107 | * |
||
| 108 | * @param string|string[] $matchingConfig |
||
| 109 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
| 110 | * @param bool $expectedResult |
||
| 111 | */ |
||
| 112 | View Code Duplication | public function testMatchLocation($matchingConfig, Repository $repository, $expectedResult) |
|
| 121 | |||
| 122 | public function matchLocationProvider() |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @expectedException \RuntimeException |
||
| 155 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::matchContentInfo |
||
| 156 | * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\UrlAlias::setMatchingConfig |
||
| 157 | */ |
||
| 158 | public function testMatchContentInfo() |
||
| 163 | } |
||
| 164 |