1717use CodeIgniter \HTTP \ResponseInterface ;
1818use CodeIgniter \HTTP \SiteURI ;
1919use CodeIgniter \HTTP \UserAgent ;
20+ use CodeIgniter \I18n \Time ;
2021use CodeIgniter \Test \CIUnitTestCase ;
2122use CodeIgniter \Test \Mock \MockAppConfig ;
2223use Config \Services ;
@@ -34,6 +35,8 @@ protected function setUp(): void
3435
3536 // Clear cache before each test
3637 cache ()->clean ();
38+
39+ Time::setTestNow ('2026-01-10 12:00:00 ' );
3740 }
3841
3942 public function testConstructorDefaults (): void
@@ -73,7 +76,7 @@ public function testBeforeReturnsCachedResponseWhenFound(): void
7376 'body ' => 'Cached content ' ,
7477 'status ' => 200 ,
7578 'headers ' => ['Content-Type ' => 'text/html ' ],
76- 'timestamp ' => time () - 10 ,
79+ 'timestamp ' => Time:: now ()-> getTimestamp () - 10 ,
7780 ];
7881 cache ()->save ($ cacheKey , $ cachedData , 3600 );
7982
@@ -124,7 +127,7 @@ public function testBeforeUsesCustomCacheKey(): void
124127 'body ' => 'Custom cached content ' ,
125128 'status ' => 200 ,
126129 'headers ' => [],
127- 'timestamp ' => time (),
130+ 'timestamp ' => Time:: now ()-> getTimestamp (),
128131 ];
129132 cache ()->save ('my_custom_key ' , $ cachedData , 3600 );
130133
0 commit comments