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 |
||
| 8 | class DateIntervalTest extends \Doctrine\Tests\DbalTestCase |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var MockPlatform |
||
| 12 | */ |
||
| 13 | private $platform; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var \Doctrine\DBAL\Types\DateIntervalType |
||
| 17 | */ |
||
| 18 | private $type; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * {@inheritDoc} |
||
| 22 | */ |
||
| 23 | protected function setUp() |
||
| 30 | |||
| 31 | View Code Duplication | public function testDateIntervalConvertsToDatabaseValue() |
|
| 40 | |||
| 41 | public function testDateIntervalConvertsToPHPValue() |
||
| 47 | |||
| 48 | public function testOldDateIntervalFormatConvertsToPHPValue() |
||
| 54 | |||
| 55 | View Code Duplication | public function testNegativeDateIntervalConvertsToDatabaseValue() |
|
| 65 | |||
| 66 | public function testNegativeDateIntervalConvertsToPHPValue() |
||
| 72 | |||
| 73 | public function testInvalidDateIntervalFormatConversion() |
||
| 78 | |||
| 79 | public function testDateIntervalNullConversion() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @group DBAL-1288 |
||
| 86 | */ |
||
| 87 | public function testRequiresSQLCommentHint() |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @dataProvider invalidPHPValuesProvider |
||
| 94 | * |
||
| 95 | * @param mixed $value |
||
| 96 | */ |
||
| 97 | public function testInvalidTypeConversionToDatabaseValue($value) |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @return mixed[][] |
||
| 106 | */ |
||
| 107 | View Code Duplication | public function invalidPHPValuesProvider() |
|
| 126 | } |
||
| 127 |