Skip to content

Commit 2993d7e

Browse files
lcobuccimorozov
authored andcommitted
Add type declarations to DateIntervalTest
1 parent ff36931 commit 2993d7e

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace Doctrine\Tests\DBAL\Types;
44

5+
use Doctrine\DBAL\Types\ConversionException;
6+
use Doctrine\DBAL\Types\DateIntervalType;
57
use Doctrine\DBAL\Types\Type;
68
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
79

8-
class DateIntervalTest extends \Doctrine\Tests\DbalTestCase
10+
final class DateIntervalTest extends \Doctrine\Tests\DbalTestCase
911
{
1012
/**
1113
* @var MockPlatform
@@ -20,15 +22,15 @@ class DateIntervalTest extends \Doctrine\Tests\DbalTestCase
2022
/**
2123
* {@inheritDoc}
2224
*/
23-
protected function setUp()
25+
protected function setUp() : void
2426
{
2527
$this->platform = new MockPlatform();
2628
$this->type = Type::getType('dateinterval');
2729

28-
self::assertInstanceOf('Doctrine\DBAL\Types\DateIntervalType', $this->type);
30+
self::assertInstanceOf(DateIntervalType::class, $this->type);
2931
}
3032

31-
public function testDateIntervalConvertsToDatabaseValue()
33+
public function testDateIntervalConvertsToDatabaseValue() : void
3234
{
3335
$interval = new \DateInterval('P2Y1DT1H2M3S');
3436

@@ -38,68 +40,66 @@ public function testDateIntervalConvertsToDatabaseValue()
3840
self::assertEquals($expected, $actual);
3941
}
4042

41-
public function testDateIntervalConvertsToPHPValue()
43+
public function testDateIntervalConvertsToPHPValue() : void
4244
{
4345
$interval = $this->type->convertToPHPValue('+P02Y00M01DT01H02M03S', $this->platform);
4446

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));
4749
}
4850

49-
public function testNegativeDateIntervalConvertsToDatabaseValue()
51+
public function testNegativeDateIntervalConvertsToDatabaseValue() : void
5052
{
5153
$interval = new \DateInterval('P2Y1DT1H2M3S');
5254
$interval->invert = 1;
5355

54-
$expected = '-P02Y00M01DT01H02M03S';
5556
$actual = $this->type->convertToDatabaseValue($interval, $this->platform);
5657

57-
self::assertEquals($expected, $actual);
58+
self::assertEquals('-P02Y00M01DT01H02M03S', $actual);
5859
}
5960

60-
public function testNegativeDateIntervalConvertsToPHPValue()
61+
public function testNegativeDateIntervalConvertsToPHPValue() : void
6162
{
6263
$interval = $this->type->convertToPHPValue('-P02Y00M01DT01H02M03S', $this->platform);
6364

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));
6667
}
6768

68-
public function testInvalidDateIntervalFormatConversion()
69+
public function testInvalidDateIntervalFormatConversion() : void
6970
{
70-
$this->expectException('Doctrine\DBAL\Types\ConversionException');
71+
$this->expectException(ConversionException::class);
72+
7173
$this->type->convertToPHPValue('abcdefg', $this->platform);
7274
}
7375

74-
public function testDateIntervalNullConversion()
76+
public function testDateIntervalNullConversion() : void
7577
{
7678
self::assertNull($this->type->convertToPHPValue(null, $this->platform));
7779
}
7880

7981
/**
8082
* @group DBAL-1288
8183
*/
82-
public function testRequiresSQLCommentHint()
84+
public function testRequiresSQLCommentHint() : void
8385
{
8486
self::assertTrue($this->type->requiresSQLCommentHint($this->platform));
8587
}
8688

8789
/**
8890
* @dataProvider invalidPHPValuesProvider
89-
*
90-
* @param mixed $value
9191
*/
92-
public function testInvalidTypeConversionToDatabaseValue($value)
92+
public function testInvalidTypeConversionToDatabaseValue($value) : void
9393
{
94-
$this->expectException('Doctrine\DBAL\Types\ConversionException');
94+
$this->expectException(ConversionException::class);
9595

9696
$this->type->convertToDatabaseValue($value, $this->platform);
9797
}
9898

9999
/**
100100
* @return mixed[][]
101101
*/
102-
public function invalidPHPValuesProvider()
102+
public function invalidPHPValuesProvider() : array
103103
{
104104
return [
105105
[0],

0 commit comments

Comments
 (0)