Skip to content

Commit

Permalink
Expand timezone deserialization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlevers committed Jul 9, 2024
1 parent 5d1e23b commit 8eef808
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tests/SerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

declare(strict_types=1);

use DateTime;
use DateTimeZone;
use DateTimeInterface;
use PHPUnit\Framework\TestCase;
use Saloon\Http\Faking\MockClient;
use Saloon\Http\Faking\MockResponse;
Expand Down Expand Up @@ -184,8 +181,21 @@ public function testDeserializeDateTimeWithTimezone(): void
],
],
]);
$this->assertNotNull($result);
$this->assertInstanceOf(DateTimeInterface::class, $result->payload->feesEstimateResult->feesEstimate->timeOfFeesEstimation);
$this->assertEquals( (new DateTimeZone('+02:00')), $result->payload->feesEstimateResult->feesEstimate->timeOfFeesEstimation->getTimeZone() );
$this->assertEquals(new DateTimeZone('+02:00'), $result->payload->feesEstimateResult->feesEstimate->timeOfFeesEstimation->getTimeZone());

$nowUtc = new DateTime();
$utcResult = GetMyFeesEstimateResponse::deserialize([
'payload' => [
'FeesEstimateResult' => [
'status' => 'Success',
'FeesEstimate' => [
'TimeOfFeesEstimation' => $nowUtc->format('Y-m-d\TH:i:s\Z'),
],
],
],
]);
$this->assertInstanceOf(DateTimeInterface::class, $utcResult->payload->feesEstimateResult->feesEstimate->timeOfFeesEstimation);
$this->assertEquals(new DateTimeZone('UTC'), $utcResult->payload->feesEstimateResult->feesEstimate->timeOfFeesEstimation->getTimeZone());
}
}

0 comments on commit 8eef808

Please sign in to comment.