Skip to content

Commit cbad424

Browse files
committed
tests: add tests for Time::isPast() and Time::isFuture()
1 parent 5f394fd commit cbad424

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/system/I18n/TimeTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,34 @@ public function testAfterWithMicroseconds(): void
10401040
$this->assertFalse($time2->isAfter($time1));
10411041
}
10421042

1043+
public function testIsPast(): void
1044+
{
1045+
Time::setTestNow('2025-12-30 12:00:00', 'Asia/Tehran');
1046+
1047+
$past = Time::parse('2025-12-30 11:59:59', 'Asia/Tehran');
1048+
$this->assertTrue($past->isPast());
1049+
1050+
$future = Time::parse('2025-12-30 12:00:01', 'Asia/Tehran');
1051+
$this->assertFalse($future->isPast());
1052+
1053+
$now = Time::now('Asia/Tehran');
1054+
$this->assertFalse($now->isPast());
1055+
}
1056+
1057+
public function testIsFuture(): void
1058+
{
1059+
Time::setTestNow('2025-12-30 12:00:00', 'Asia/Tehran');
1060+
1061+
$future = Time::parse('2025-12-30 12:00:01', 'Asia/Tehran');
1062+
$this->assertTrue($future->isFuture());
1063+
1064+
$past = Time::parse('2025-12-30 11:59:59', 'Asia/Tehran');
1065+
$this->assertFalse($past->isFuture());
1066+
1067+
$now = Time::now('Asia/Tehran');
1068+
$this->assertFalse($now->isFuture());
1069+
}
1070+
10431071
public function testHumanizeYearsSingle(): void
10441072
{
10451073
Time::setTestNow('March 10, 2017', 'America/Chicago');

0 commit comments

Comments
 (0)