File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -399,10 +399,15 @@ public function testGetTimestamp(): void
399399
400400 public function testGetAge (): void
401401 {
402+ // setTestNow() does not work to parse().
402403 $ time = TimeLegacy::parse ('5 years ago ' );
403404
404- $ this ->assertSame (5 , $ time ->getAge ());
405- $ this ->assertSame (5 , $ time ->age );
405+ // Considers leap year
406+ $ now = TimeLegacy::now ();
407+ $ expected = ($ now ->day === '29 ' && $ now ->month === '2 ' ) ? 4 : 5 ;
408+
409+ $ this ->assertSame ($ expected , $ time ->getAge ());
410+ $ this ->assertSame ($ expected , $ time ->age );
406411 }
407412
408413 public function testAgeNow (): void
Original file line number Diff line number Diff line change @@ -406,10 +406,15 @@ public function testGetTimestamp(): void
406406 */
407407 public function testGetAge (): void
408408 {
409+ // setTestNow() does not work to parse().
409410 $ time = Time::parse ('5 years ago ' );
410411
411- $ this ->assertSame (5 , $ time ->getAge ());
412- $ this ->assertSame (5 , $ time ->age );
412+ // Considers leap year
413+ $ now = Time::now ();
414+ $ expected = ($ now ->day === '29 ' && $ now ->month === '2 ' ) ? 4 : 5 ;
415+
416+ $ this ->assertSame ($ expected , $ time ->getAge ());
417+ $ this ->assertSame ($ expected , $ time ->age );
413418 }
414419
415420 public function testAgeNow (): void
You can’t perform that action at this time.
0 commit comments