Skip to content

Commit

Permalink
gmmktime: make test a bit more debuggable and understandable
Browse files Browse the repository at this point in the history
  • Loading branch information
asprega committed May 27, 2022
1 parent 51e046a commit 7207b3f
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions tests/ClockMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,45 @@ public function test_gmstrftime()

public function dateProvider_gmmktime(): array
{
// NOTE: for all datasets, hour in freezeDateTime is completely irrelevant because always overridden by $hour
// parameter provided to gmmktime. Also, in expectedDateTime hour is always "13" because hour 10 in GMT
// corresponds to hour 13 when we are in +03:00 offset.
return [
['2022-04-04 14:26:29.123456', [10], '2022-04-04 13:26:29.123456'],
['2022-04-04 14:26:29.123456', [10, 10], '2022-04-04 13:10:29.123456'],
['2022-04-04 14:26:29.123456', [10, null, 10], '2022-04-04 13:26:10.123456'],
['2022-04-04 14:26:29.123456', [10, null, null, 10], '2022-10-04 13:26:29.123456'],
['2022-04-04 14:26:29.123456', [10, null, null, null, 10], '2022-04-10 13:26:29.123456'],
['2022-04-04 14:26:29.123456', [10, null, null, null, null, 10], '2010-04-04 13:26:29.123456'],
['2022-04-04 14:26:29.123456', [10, 10, 10, 10, 10, 10], '2010-10-10 13:10:10.123456'],
[
'2022-04-04T05:26:29+03:00',
[10],
'2022-04-04T13:26:29+00:00'
],
[
'2022-04-04T05:26:29+03:00',
[10, 10],
'2022-04-04T13:10:29+00:00'
],
[
'2022-04-04T05:26:29+03:00',
[10, null, 10],
'2022-04-04T13:26:10+00:00'
],
[
'2022-04-04T05:26:29+03:00',
[10, null, null, 10],
'2022-10-04T13:26:29+00:00'
],
[
'2022-04-04T05:26:29+03:00',
[10, null, null, null, 10],
'2022-04-10T13:26:29+00:00'
],
[
'2022-04-04T05:26:29+03:00',
[10, null, null, null, null, 10],
'2010-04-04T13:26:29+00:00'
],
[
'2022-04-04T05:26:29+03:00',
[10, 10, 10, 10, 10, 10],
'2010-10-10T13:10:10+00:00'
],
];
}

Expand All @@ -200,9 +231,9 @@ public function dateProvider_gmmktime(): array
*/
public function test_gmmktime(string $freezeDateTime, array $mktimeArgs, string $expectedDateTime)
{
ClockMock::freeze((new \DateTime($freezeDateTime))->setTimezone(new \DateTimeZone('Europe/Kiev')));
ClockMock::freeze(new \DateTime($freezeDateTime));

$this->assertEquals($expected = strtotime($expectedDateTime), $actual = gmmktime(...$mktimeArgs));
$this->assertEquals($expectedDateTime, date(DATE_ATOM, gmmktime(...$mktimeArgs)));
}

public function test_idate()
Expand Down

0 comments on commit 7207b3f

Please sign in to comment.