2
2
3
3
namespace Doctrine \Tests \DBAL \Types ;
4
4
5
+ use Doctrine \DBAL \Types \ConversionException ;
6
+ use Doctrine \DBAL \Types \DateIntervalType ;
5
7
use Doctrine \DBAL \Types \Type ;
6
8
use Doctrine \Tests \DBAL \Mocks \MockPlatform ;
7
9
8
- class DateIntervalTest extends \Doctrine \Tests \DbalTestCase
10
+ final class DateIntervalTest extends \Doctrine \Tests \DbalTestCase
9
11
{
10
12
/**
11
13
* @var MockPlatform
@@ -20,15 +22,15 @@ class DateIntervalTest extends \Doctrine\Tests\DbalTestCase
20
22
/**
21
23
* {@inheritDoc}
22
24
*/
23
- protected function setUp ()
25
+ protected function setUp () : void
24
26
{
25
27
$ this ->platform = new MockPlatform ();
26
28
$ this ->type = Type::getType ('dateinterval ' );
27
29
28
- self ::assertInstanceOf (' Doctrine\DBAL\Types\ DateIntervalType' , $ this ->type );
30
+ self ::assertInstanceOf (DateIntervalType::class , $ this ->type );
29
31
}
30
32
31
- public function testDateIntervalConvertsToDatabaseValue ()
33
+ public function testDateIntervalConvertsToDatabaseValue () : void
32
34
{
33
35
$ interval = new \DateInterval ('P2Y1DT1H2M3S ' );
34
36
@@ -38,68 +40,66 @@ public function testDateIntervalConvertsToDatabaseValue()
38
40
self ::assertEquals ($ expected , $ actual );
39
41
}
40
42
41
- public function testDateIntervalConvertsToPHPValue ()
43
+ public function testDateIntervalConvertsToPHPValue () : void
42
44
{
43
45
$ interval = $ this ->type ->convertToPHPValue ('+P02Y00M01DT01H02M03S ' , $ this ->platform );
44
46
45
- self ::assertInstanceOf (' DateInterval ' , $ interval );
46
- self ::assertEquals ('+P02Y00M01DT01H02M03S ' , $ interval ->format (' %RP%YY%MM%DDT%HH%IM%SS ' ));
47
+ self ::assertInstanceOf (\ DateInterval::class , $ interval );
48
+ self ::assertEquals ('+P02Y00M01DT01H02M03S ' , $ interval ->format (DateIntervalType:: FORMAT ));
47
49
}
48
50
49
- public function testNegativeDateIntervalConvertsToDatabaseValue ()
51
+ public function testNegativeDateIntervalConvertsToDatabaseValue () : void
50
52
{
51
53
$ interval = new \DateInterval ('P2Y1DT1H2M3S ' );
52
54
$ interval ->invert = 1 ;
53
55
54
- $ expected = '-P02Y00M01DT01H02M03S ' ;
55
56
$ actual = $ this ->type ->convertToDatabaseValue ($ interval , $ this ->platform );
56
57
57
- self ::assertEquals ($ expected , $ actual );
58
+ self ::assertEquals (' -P02Y00M01DT01H02M03S ' , $ actual );
58
59
}
59
60
60
- public function testNegativeDateIntervalConvertsToPHPValue ()
61
+ public function testNegativeDateIntervalConvertsToPHPValue () : void
61
62
{
62
63
$ interval = $ this ->type ->convertToPHPValue ('-P02Y00M01DT01H02M03S ' , $ this ->platform );
63
64
64
- self ::assertInstanceOf (' DateInterval ' , $ interval );
65
- self ::assertEquals ('-P02Y00M01DT01H02M03S ' , $ interval ->format (' %RP%YY%MM%DDT%HH%IM%SS ' ));
65
+ self ::assertInstanceOf (\ DateInterval::class , $ interval );
66
+ self ::assertEquals ('-P02Y00M01DT01H02M03S ' , $ interval ->format (DateIntervalType:: FORMAT ));
66
67
}
67
68
68
- public function testInvalidDateIntervalFormatConversion ()
69
+ public function testInvalidDateIntervalFormatConversion () : void
69
70
{
70
- $ this ->expectException ('Doctrine\DBAL\Types\ConversionException ' );
71
+ $ this ->expectException (ConversionException::class);
72
+
71
73
$ this ->type ->convertToPHPValue ('abcdefg ' , $ this ->platform );
72
74
}
73
75
74
- public function testDateIntervalNullConversion ()
76
+ public function testDateIntervalNullConversion () : void
75
77
{
76
78
self ::assertNull ($ this ->type ->convertToPHPValue (null , $ this ->platform ));
77
79
}
78
80
79
81
/**
80
82
* @group DBAL-1288
81
83
*/
82
- public function testRequiresSQLCommentHint ()
84
+ public function testRequiresSQLCommentHint () : void
83
85
{
84
86
self ::assertTrue ($ this ->type ->requiresSQLCommentHint ($ this ->platform ));
85
87
}
86
88
87
89
/**
88
90
* @dataProvider invalidPHPValuesProvider
89
- *
90
- * @param mixed $value
91
91
*/
92
- public function testInvalidTypeConversionToDatabaseValue ($ value )
92
+ public function testInvalidTypeConversionToDatabaseValue ($ value ) : void
93
93
{
94
- $ this ->expectException (' Doctrine\DBAL\Types\ ConversionException' );
94
+ $ this ->expectException (ConversionException::class );
95
95
96
96
$ this ->type ->convertToDatabaseValue ($ value , $ this ->platform );
97
97
}
98
98
99
99
/**
100
100
* @return mixed[][]
101
101
*/
102
- public function invalidPHPValuesProvider ()
102
+ public function invalidPHPValuesProvider () : array
103
103
{
104
104
return [
105
105
[0 ],
0 commit comments