Skip to content

Commit 7b0d8c3

Browse files
committed
test: add test for DataConverter to convert datetime to db with microseconds
1 parent 4932e44 commit 7b0d8c3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/system/DataConverter/DataConverterTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,23 @@ public function testDateTimeConvertDataToDB(): void
379379
$this->assertSame('2023-11-18 14:18:18', $data['date']);
380380
}
381381

382+
public function testDateTimeConvertDataToDBWithFormat(): void
383+
{
384+
$types = [
385+
'id' => 'int',
386+
'date' => 'datetime[us]',
387+
];
388+
$converter = $this->createDataConverter($types, [], db_connect());
389+
390+
$phpData = [
391+
'id' => '1',
392+
'date' => Time::parse('2009-02-15 00:00:01.123456'),
393+
];
394+
$data = $converter->toDataSource($phpData);
395+
396+
$this->assertSame('2009-02-15 00:00:01.123456', $data['date']);
397+
}
398+
382399
public function testTimestampConvertDataFromDB(): void
383400
{
384401
$types = [

0 commit comments

Comments
 (0)