From 0689989318dfb78a655dac5c6de114db8006dd26 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Mon, 22 Jun 2026 17:44:12 +0000 Subject: [PATCH] fix(tests): remove Post_Assembler eval stub from SyncModeTest (breaks Publisher tests) SyncModeTest runs alphabetically before GenerationCheckpointRunnerTest and PublisherSideEffectsTest. Defining PRAutoBlogger_Post_Assembler via eval with only amortize_research_costs() caused Publisher* and ResearchReaper tests to fail with 'Call to undefined method sanitize_llm_content()' because the stub registered before the autoloader could load the real class. Fix: remove the Post_Assembler eval block entirely from both generate-tick tests. The 'more ideas remain' path (2-idea queue, pop one) never calls Post_Assembler::amortize_research_costs() -- that only runs in the last-idea branch. No stub is needed. Article_Worker stub is retained (it IS called in this path and needs a no-op generate() to avoid real LLM calls). Agent-Session: prab-reliability-test-fix-20260622 --- ...GenerationCheckpointRunnerSyncModeTest.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/unit/Core/GenerationCheckpointRunnerSyncModeTest.php b/tests/unit/Core/GenerationCheckpointRunnerSyncModeTest.php index 9a3e63a..668b398 100644 --- a/tests/unit/Core/GenerationCheckpointRunnerSyncModeTest.php +++ b/tests/unit/Core/GenerationCheckpointRunnerSyncModeTest.php @@ -159,6 +159,12 @@ class GenerationCheckpointRunnerSyncModeTest extends BaseTestCase { /** * sync_mode=true + 2 ideas in queue: on_generate_tick() must not reschedule * GENERATE_ACTION or call spawn_cron (VPS loop is the sole driver of next tick). + * + * Uses 2 ideas so the code stays in the "more ideas remain" branch -- this + * path calls Article_Worker->generate() and then the sync guard, never + * Post_Assembler::amortize_research_costs() (that is in the last-idea branch). + * Article_Worker is stubbed; Post_Assembler is not needed and must NOT be + * redefined here to avoid clobbering the real class for downstream tests. */ public function test_generate_tick_sync_mode_suppresses_reschedule(): void { $run_id = 'sync-gen-tick-uuid'; @@ -175,6 +181,10 @@ class GenerationCheckpointRunnerSyncModeTest extends BaseTestCase { $wpdb->method( 'query' )->willReturn( 1 ); $wpdb->method( 'get_var' )->willReturn( null ); + // Stub Article_Worker only -- Post_Assembler is NOT stubbed here because + // amortize_research_costs() is not called on the "more ideas remain" path, + // and redefining it with an incomplete stub breaks Publisher tests that run + // after this file (alphabetical: SyncModeTest < Test). if ( ! class_exists( 'PRAutoBlogger_Article_Worker', false ) ) { // phpcs:ignore Squiz.Strings.DoubleQuoteUsage.NotRequired eval( 'class PRAutoBlogger_Article_Worker { @@ -182,10 +192,6 @@ class GenerationCheckpointRunnerSyncModeTest extends BaseTestCase { public function generate($idea){ return ["generated"=>1,"published"=>1,"rejected"=>0,"cost"=>0.01]; } }' ); } - if ( ! class_exists( 'PRAutoBlogger_Post_Assembler', false ) ) { - // phpcs:ignore Squiz.Strings.DoubleQuoteUsage.NotRequired - eval( 'class PRAutoBlogger_Post_Assembler { public static function amortize_research_costs($r){} }' ); - } \PRAutoBlogger_Generation_Checkpoint_Runner::set_sync_mode( true ); \PRAutoBlogger_Generation_Checkpoint_Runner::on_generate_tick(); @@ -222,6 +228,7 @@ class GenerationCheckpointRunnerSyncModeTest extends BaseTestCase { $wpdb->method( 'query' )->willReturn( 1 ); $wpdb->method( 'get_var' )->willReturn( null ); + // Article_Worker stub only -- see note in test_generate_tick_sync_mode_suppresses_reschedule. if ( ! class_exists( 'PRAutoBlogger_Article_Worker', false ) ) { // phpcs:ignore Squiz.Strings.DoubleQuoteUsage.NotRequired eval( 'class PRAutoBlogger_Article_Worker { @@ -229,10 +236,6 @@ class GenerationCheckpointRunnerSyncModeTest extends BaseTestCase { public function generate($idea){ return ["generated"=>1,"published"=>1,"rejected"=>0,"cost"=>0.01]; } }' ); } - if ( ! class_exists( 'PRAutoBlogger_Post_Assembler', false ) ) { - // phpcs:ignore Squiz.Strings.DoubleQuoteUsage.NotRequired - eval( 'class PRAutoBlogger_Post_Assembler { public static function amortize_research_costs($r){} }' ); - } \PRAutoBlogger_Generation_Checkpoint_Runner::set_sync_mode( false ); \PRAutoBlogger_Generation_Checkpoint_Runner::on_generate_tick();