-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: corrects timezone setting in DateTimeRFC::UTCfrom
- Loading branch information
1 parent
9ce6916
commit 2bf2d55
Showing
2 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Unit\DDDStarterPack\Type; | ||
|
||
use DDDStarterPack\Type\DateTimeRFC; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DateTimeRFCTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_should_create_utc_date_time_from_different_timezone_date_time_string(): void | ||
{ | ||
$now = new DateTimeRFC('2024-06-27T21:06:37.879786+02:00'); | ||
$nowToUTC = DateTimeRFC::UTCfrom($now->value()); | ||
|
||
self::assertSame('2024-06-27T21:06:37.879786+02:00', $now->value()); | ||
self::assertSame('2024-06-27T19:06:37.879786+00:00', $nowToUTC->value()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_should_create_utc_date_time(): void | ||
{ | ||
$utc = DateTimeRFC::UTC(); | ||
|
||
$timezone = $utc->getTimezone(); | ||
self::assertInstanceOf(\DateTimeZone::class, $timezone); | ||
self::assertSame('UTC', $timezone->getName()); | ||
} | ||
} |