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 ContentViewTest extends AbstractViewTest |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Params that are always returned by this view. |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | private $valueParams = ['content' => null]; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @dataProvider constructProvider |
||
| 27 | * @covers \eZ\Publish\Core\MVC\Symfony\View\ContentView::__construct |
||
| 28 | * @covers \eZ\Publish\Core\MVC\Symfony\View\ContentView::getTemplateIdentifier |
||
| 29 | * @covers \eZ\Publish\Core\MVC\Symfony\View\ContentView::getParameters |
||
| 30 | */ |
||
| 31 | public function testConstruct($templateIdentifier, array $params) |
||
| 37 | |||
| 38 | public function constructProvider() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @dataProvider constructFailProvider |
||
| 61 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType |
||
| 62 | * @covers \eZ\Publish\Core\MVC\Symfony\View\ContentView::__construct |
||
| 63 | */ |
||
| 64 | public function testConstructFail($templateIdentifier) |
||
| 68 | |||
| 69 | View Code Duplication | public function constructFailProvider() |
|
| 77 | |||
| 78 | protected function createViewUnderTest($template = null, array $parameters = [], $viewType = 'full'): View |
||
| 82 | |||
| 83 | protected function getAlwaysAvailableParams(): array |
||
| 87 | } |
||
| 88 |