diff --git a/tests/system/I18n/TimeLegacyTest.php b/tests/system/I18n/TimeLegacyTest.php index 36907988349d..9f013a0ddcbe 100644 --- a/tests/system/I18n/TimeLegacyTest.php +++ b/tests/system/I18n/TimeLegacyTest.php @@ -399,10 +399,15 @@ public function testGetTimestamp(): void public function testGetAge(): void { + // setTestNow() does not work to parse(). $time = TimeLegacy::parse('5 years ago'); - $this->assertSame(5, $time->getAge()); - $this->assertSame(5, $time->age); + // Considers leap year + $now = TimeLegacy::now(); + $expected = ($now->day === '29' && $now->month === '2') ? 4 : 5; + + $this->assertSame($expected, $time->getAge()); + $this->assertSame($expected, $time->age); } public function testAgeNow(): void diff --git a/tests/system/I18n/TimeTest.php b/tests/system/I18n/TimeTest.php index d60fb4410a03..f5bca98268fb 100644 --- a/tests/system/I18n/TimeTest.php +++ b/tests/system/I18n/TimeTest.php @@ -406,10 +406,15 @@ public function testGetTimestamp(): void */ public function testGetAge(): void { + // setTestNow() does not work to parse(). $time = Time::parse('5 years ago'); - $this->assertSame(5, $time->getAge()); - $this->assertSame(5, $time->age); + // Considers leap year + $now = Time::now(); + $expected = ($now->day === '29' && $now->month === '2') ? 4 : 5; + + $this->assertSame($expected, $time->getAge()); + $this->assertSame($expected, $time->age); } public function testAgeNow(): void