Skip to content

Commit 764abe5

Browse files
committed
Make BaseDateTypeTestCase generic
1 parent 74a6637 commit 764abe5

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ parameters:
9494
- '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapNumericRow\(\) expects list<string\|null>, .* given\.$~'
9595

9696
# Required for Psalm compatibility
97-
- '~^Property Doctrine\\DBAL\\Tests\\Types\\BaseDateTypeTestCase\:\:\$currentTimezone \(non-empty-string\) does not accept string\.$~'
97+
- '~^Property Doctrine\\DBAL\\Tests\\Types\\BaseDateTypeTestCase<TType of Doctrine\\DBAL\\Types\\Type>\:\:\$currentTimezone \(non-empty-string\) does not accept string\.$~'
9898

9999
# The @throws annotations are part of a contract. Even if the default implementation doen't throw those
100100
# exceptions, the child implementations might do so.

tests/Types/BaseDateTypeTestCase.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@
99
use Doctrine\DBAL\Types\ConversionException;
1010
use Doctrine\DBAL\Types\Type;
1111
use PHPUnit\Framework\Attributes\DataProvider;
12-
use PHPUnit\Framework\MockObject\MockObject;
12+
use PHPUnit\Framework\MockObject\Stub;
1313
use PHPUnit\Framework\TestCase;
1414
use stdClass;
1515

1616
use function date_default_timezone_get;
1717
use function date_default_timezone_set;
1818

19+
/** @template TType of Type */
1920
abstract class BaseDateTypeTestCase extends TestCase
2021
{
21-
protected AbstractPlatform&MockObject $platform;
22+
protected AbstractPlatform&Stub $platform;
23+
24+
/** @var TType */
2225
protected Type $type;
2326

2427
/** @var non-empty-string */
2528
private string $currentTimezone;
2629

2730
protected function setUp(): void
2831
{
29-
$this->platform = $this->createMock(AbstractPlatform::class);
32+
$this->platform = self::createStub(AbstractPlatform::class);
3033
$this->currentTimezone = date_default_timezone_get();
3134
}
3235

tests/Types/DateTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use function date_default_timezone_set;
1212

13+
/** @extends BaseDateTypeTestCase<DateType> */
1314
class DateTest extends BaseDateTypeTestCase
1415
{
1516
protected function setUp(): void

tests/Types/DateTimeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\DBAL\Types\ConversionException;
99
use Doctrine\DBAL\Types\DateTimeType;
1010

11+
/** @extends BaseDateTypeTestCase<DateTimeType> */
1112
class DateTimeTest extends BaseDateTypeTestCase
1213
{
1314
protected function setUp(): void

tests/Types/DateTimeTzTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\DBAL\Types\ConversionException;
99
use Doctrine\DBAL\Types\DateTimeTzType;
1010

11+
/** @extends BaseDateTypeTestCase<DateTimeTzType> */
1112
class DateTimeTzTest extends BaseDateTypeTestCase
1213
{
1314
protected function setUp(): void

tests/Types/TimeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\DBAL\Types\ConversionException;
99
use Doctrine\DBAL\Types\TimeType;
1010

11+
/** @extends BaseDateTypeTestCase<TimeType> */
1112
class TimeTest extends BaseDateTypeTestCase
1213
{
1314
protected function setUp(): void

0 commit comments

Comments
 (0)