Skip to content

Commit

Permalink
test: add test for DataConverter to convert datetime to db with micro…
Browse files Browse the repository at this point in the history
…seconds
  • Loading branch information
kenjis committed Jul 29, 2024
1 parent 86f51ef commit 5d1ad1e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/system/DataConverter/DataConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,23 @@ public function testDateTimeConvertDataToDB(): void
$this->assertSame('2023-11-18 14:18:18', $data['date']);
}

public function testDateTimeConvertDataToDBWithFormat(): void
{
$types = [
'id' => 'int',
'date' => 'datetime[us]',
];
$converter = $this->createDataConverter($types, [], db_connect());

$phpData = [
'id' => '1',
'date' => Time::parse('2009-02-15 00:00:01.123456'),
];
$data = $converter->toDataSource($phpData);

$this->assertSame('2009-02-15 00:00:01.123456', $data['date']);
}

public function testTimestampConvertDataFromDB(): void
{
$types = [
Expand Down

0 comments on commit 5d1ad1e

Please sign in to comment.