From 1f00288aeff9ba1a4fee9d394de464b11c9217d4 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sun, 4 May 2025 18:48:33 +0700 Subject: [PATCH] Update tests --- tests/MagicActiveRecordTest.php | 8 ++++++-- tests/Stubs/ActiveRecord/Type.php | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/MagicActiveRecordTest.php b/tests/MagicActiveRecordTest.php index 165b9a4e7..e4c3dd13e 100644 --- a/tests/MagicActiveRecordTest.php +++ b/tests/MagicActiveRecordTest.php @@ -5,6 +5,7 @@ namespace Yiisoft\ActiveRecord\Tests; use DateTimeImmutable; +use DateTimeZone; use DivisionByZeroError; use ReflectionException; use Yiisoft\ActiveRecord\ActiveQuery; @@ -158,9 +159,12 @@ public function testDefaultValues(): void $this->assertEquals(1.23, $arClass->float_col2); $this->assertEquals(33.22, $arClass->numeric_col); $this->assertTrue($arClass->bool_col2); - $this->assertEquals('2002-01-01 00:00:00', $arClass->time); - if ($this->db()->getDriverName() !== 'mysql') { + if ($this->db()->getDriverName() === 'mysql') { + $dbTimezone = $this->db()->getServerInfo()->getTimezone(); + $this->assertEquals(new DateTimeImmutable('2002-01-01 00:00:00', new DateTimeZone($dbTimezone)), $arClass->time); + } else { + $this->assertEquals(new DateTimeImmutable('2002-01-01 00:00:00'), $arClass->time); $this->assertSame(['a' => 1], $arClass->json_col); } diff --git a/tests/Stubs/ActiveRecord/Type.php b/tests/Stubs/ActiveRecord/Type.php index 421df9204..f3c0a3a64 100644 --- a/tests/Stubs/ActiveRecord/Type.php +++ b/tests/Stubs/ActiveRecord/Type.php @@ -4,6 +4,7 @@ namespace Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord; +use DateTimeInterface; use Yiisoft\ActiveRecord\ActiveRecord; use Yiisoft\Db\Expression\Expression; @@ -23,10 +24,10 @@ class Type extends ActiveRecord public float|null $float_col2 = 1.23; public mixed $blob_col; public float|null $numeric_col = 33.22; - public string|Expression $time = '2002-01-01 00:00:00'; + public string|DateTimeInterface|Expression $time = '2002-01-01 00:00:00'; public bool|int|string $bool_col; public bool|int|string|null $bool_col2 = true; - public string|Expression $ts_default; + public DateTimeInterface|Expression $ts_default; public int|string $bit_col = 0b1000_0010; public array|null $json_col = null;