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 | abstract class BaseDateTypeTestCase extends PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | /** |
||
11 | * @var MockPlatform |
||
12 | */ |
||
13 | protected $platform; |
||
14 | |||
15 | /** |
||
16 | * @var \Doctrine\DBAL\Types\Type |
||
17 | */ |
||
18 | protected $type; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $currentTimezone; |
||
24 | |||
25 | /** |
||
26 | * {@inheritDoc} |
||
27 | */ |
||
28 | protected function setUp() |
||
35 | |||
36 | /** |
||
37 | * {@inheritDoc} |
||
38 | */ |
||
39 | protected function tearDown() |
||
43 | |||
44 | public function testDateConvertsToDatabaseValue() |
||
48 | |||
49 | /** |
||
50 | * @dataProvider invalidPHPValuesProvider |
||
51 | * |
||
52 | * @param mixed $value |
||
53 | */ |
||
54 | public function testInvalidTypeConversionToDatabaseValue($value) |
||
60 | |||
61 | public function testNullConversion() |
||
65 | |||
66 | public function testConvertDateTimeToPHPValue() |
||
72 | |||
73 | /** |
||
74 | * @group #2794 |
||
75 | * |
||
76 | * Note that while DateTimeImmutable is supposed to be handled by @see \Doctrine\DBAL\Types\DateTimeImmutableType, |
||
77 | * previous DBAL versions handled it just fine. This test is just in place to prevent further regressions, even |
||
78 | * if the type is being misused |
||
79 | */ |
||
80 | public function testConvertDateTimeImmutableToPHPValue() |
||
86 | |||
87 | /** |
||
88 | * @group #2794 |
||
89 | * |
||
90 | * Note that while DateTimeImmutable is supposed to be handled by @see \Doctrine\DBAL\Types\DateTimeImmutableType, |
||
91 | * previous DBAL versions handled it just fine. This test is just in place to prevent further regressions, even |
||
92 | * if the type is being misused |
||
93 | */ |
||
94 | public function testDateTimeImmutableConvertsToDatabaseValue() |
||
101 | |||
102 | /** |
||
103 | * @return mixed[][] |
||
104 | */ |
||
105 | View Code Duplication | public function invalidPHPValuesProvider() |
|
123 | } |
||
124 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.