Debian Codegraph @

tests/classes/DateTimeTest.php

raw symbols SCIP
1 <?php
2
3 namespace Liuch\DmarcSrg;
4
5 class DateTimeTest extends \PHPUnit\Framework\TestCase
6 {
7 public function testSimpleJsonSerialize(): void
8 {
9 $this->assertJsonStringEqualsJsonString(
10 '[ "2022-10-15T18:35:20+00:00" ]',
11 \json_encode([ new DateTime('2022-10-15 18:35:20') ])
12 );
13 }
14
15 public function testUnixTimestampJsonSerialize(): void
16 {
17 $this->assertJsonStringEqualsJsonString(
18 '[ "1970-01-01T00:00:01+00:00" ]',
19 \json_encode([ new DateTime('@1') ])
20 );
21 }
22
23 public function testCurrentTimeJsonSerialize(): void
24 {
25 $now = new DateTime();
26 $this->assertJsonStringEqualsJsonString(
27 " [ \"{$now->format(\DateTime::ATOM)}\" ]",
28 \json_encode([ $now ])
29 );
30 }
31 }