Skip to content

Commit 591e8fa

Browse files
committed
test: remove the time depandency at redirectExceptionTest.php
1 parent 9da0f4f commit 591e8fa

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/system/HTTP/RedirectExceptionTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\HTTP;
1313

1414
use CodeIgniter\HTTP\Exceptions\RedirectException;
15+
use CodeIgniter\I18n\Time;
1516
use CodeIgniter\Log\Logger;
1617
use CodeIgniter\Test\Mock\MockLogger as LoggerConfig;
1718
use Config\Services;
@@ -67,8 +68,10 @@ public function testResponseWithoutStatusCode(): void
6768

6869
public function testLoggingLocationHeader(): void
6970
{
71+
Time::setTestNow('2023-11-25 12:00:00');
72+
7073
$uri = 'http://location';
71-
$expected = 'INFO - ' . date('Y-m-d') . ' --> REDIRECTED ROUTE at ' . $uri;
74+
$expected = 'INFO - ' . Time::now()->format('Y-m-d') . ' --> REDIRECTED ROUTE at ' . $uri;
7275
$response = (new RedirectException(Services::response()->redirect($uri)))->getResponse();
7376

7477
$logs = TestHandler::getLogs();
@@ -80,8 +83,10 @@ public function testLoggingLocationHeader(): void
8083

8184
public function testLoggingRefreshHeader(): void
8285
{
86+
Time::setTestNow('2023-11-25 12:00:00');
87+
8388
$uri = 'http://location';
84-
$expected = 'INFO - ' . date('Y-m-d') . ' --> REDIRECTED ROUTE at ' . $uri;
89+
$expected = 'INFO - ' . Time::now()->format('Y-m-d') . ' --> REDIRECTED ROUTE at ' . $uri;
8590
$response = (new RedirectException(Services::response()->redirect($uri, 'refresh')))->getResponse();
8691

8792
$logs = TestHandler::getLogs();

0 commit comments

Comments
 (0)