From cc984de9f076d6af88bc41dda6649836181dd474 Mon Sep 17 00:00:00 2001 From: peptiderepo <273788462+peptiderepo@users.noreply.github.com> Date: Tue, 14 Apr 2026 17:57:05 +0700 Subject: [PATCH] test: mock current_time() in BaseTestCase setUp via Brain Monkey Returns a fixed timestamp (2026-04-14) so Logger writes work and tests are reproducible. Functions\when()->alias is the correct pattern here, not a global function definition (which trips Patchwork). Agent-Session: cowork-ci-parity-20260414 --- tests/unit/BaseTestCase.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unit/BaseTestCase.php b/tests/unit/BaseTestCase.php index 4a9cf68..2349e3b 100644 --- a/tests/unit/BaseTestCase.php +++ b/tests/unit/BaseTestCase.php @@ -38,6 +38,15 @@ abstract class BaseTestCase extends TestCase { // home_url is used by OpenRouter provider in request headers. Functions\when( 'home_url' )->justReturn( 'https://test.example.com' ); + + // current_time is called by Logger on every log write. Stub returns a + // deterministic timestamp so tests are reproducible. + Functions\when( 'current_time' )->alias( static function ( $type = 'mysql', $gmt = 0 ) { + if ( $type === 'timestamp' || $type === 'U' ) { + return 1744588800; // 2026-04-14 00:00:00 UTC + } + return '2026-04-14 00:00:00'; + } ); } /**