Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ parameters:
- '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapNumericRow\(\) expects list<string\|null>, .* given\.$~'

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

# The @throws annotations are part of a contract. Even if the default implementation doen't throw those
# exceptions, the child implementations might do so.
Expand Down
9 changes: 6 additions & 3 deletions tests/Types/BaseDateTypeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use stdClass;

use function date_default_timezone_get;
use function date_default_timezone_set;

/** @template TType of Type */
abstract class BaseDateTypeTestCase extends TestCase
{
protected AbstractPlatform&MockObject $platform;
protected AbstractPlatform&Stub $platform;

/** @var TType */
protected Type $type;

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

protected function setUp(): void
{
$this->platform = $this->createMock(AbstractPlatform::class);
$this->platform = self::createStub(AbstractPlatform::class);
$this->currentTimezone = date_default_timezone_get();
}

Expand Down
1 change: 1 addition & 0 deletions tests/Types/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use function date_default_timezone_set;

/** @extends BaseDateTypeTestCase<DateType> */
class DateTest extends BaseDateTypeTestCase
{
protected function setUp(): void
Expand Down
1 change: 1 addition & 0 deletions tests/Types/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeType;

/** @extends BaseDateTypeTestCase<DateTimeType> */
class DateTimeTest extends BaseDateTypeTestCase
{
protected function setUp(): void
Expand Down
1 change: 1 addition & 0 deletions tests/Types/DateTimeTzTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeTzType;

/** @extends BaseDateTypeTestCase<DateTimeTzType> */
class DateTimeTzTest extends BaseDateTypeTestCase
{
protected function setUp(): void
Expand Down
1 change: 1 addition & 0 deletions tests/Types/TimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\TimeType;

/** @extends BaseDateTypeTestCase<TimeType> */
class TimeTest extends BaseDateTypeTestCase
{
protected function setUp(): void
Expand Down