Skip to content

Commit 05c8a56

Browse files
authored
Update tests (#416)
1 parent 7f103e7 commit 05c8a56

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

tests/MagicActiveRecordTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Yiisoft\ActiveRecord\Tests;
66

77
use DateTimeImmutable;
8+
use DateTimeZone;
89
use DivisionByZeroError;
910
use Yiisoft\ActiveRecord\ActiveQuery;
1011
use Yiisoft\ActiveRecord\Tests\Stubs\MagicActiveRecord\Alpha;
@@ -151,9 +152,12 @@ public function testDefaultValues(): void
151152
$this->assertEquals(1.23, $arClass->float_col2);
152153
$this->assertEquals(33.22, $arClass->numeric_col);
153154
$this->assertTrue($arClass->bool_col2);
154-
$this->assertEquals('2002-01-01 00:00:00', $arClass->time);
155155

156-
if ($this->db()->getDriverName() !== 'mysql') {
156+
if ($this->db()->getDriverName() === 'mysql') {
157+
$dbTimezone = $this->db()->getServerInfo()->getTimezone();
158+
$this->assertEquals(new DateTimeImmutable('2002-01-01 00:00:00', new DateTimeZone($dbTimezone)), $arClass->time);
159+
} else {
160+
$this->assertEquals(new DateTimeImmutable('2002-01-01 00:00:00'), $arClass->time);
157161
$this->assertSame(['a' => 1], $arClass->json_col);
158162
}
159163

tests/Stubs/ActiveRecord/Type.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord;
66

7+
use DateTimeInterface;
78
use Yiisoft\ActiveRecord\ActiveRecord;
89
use Yiisoft\Db\Expression\Expression;
910

@@ -23,10 +24,10 @@ class Type extends ActiveRecord
2324
public float|null $float_col2 = 1.23;
2425
public mixed $blob_col;
2526
public float|null $numeric_col = 33.22;
26-
public string|Expression $time = '2002-01-01 00:00:00';
27+
public string|DateTimeInterface|Expression $time = '2002-01-01 00:00:00';
2728
public bool|int|string $bool_col;
2829
public bool|int|string|null $bool_col2 = true;
29-
public string|Expression $ts_default;
30+
public DateTimeInterface|Expression $ts_default;
3031
public int|string $bit_col = 0b1000_0010;
3132
public array|null $json_col = null;
3233

0 commit comments

Comments
 (0)