fix: bound get_run_io() + implement gen-history null-wpdb test (#177, v0.27.1)

Closes the two M4 P2s: LIMIT 100 safety cap on the per-run stage-I/O query; implements the previously-stubbed get_page() null-wpdb test. QA APPROVE; CI green.

Agent-Session: pipeline-p2-cleanup-merge
This commit is contained in:
peptiderepo
2026-06-23 18:25:37 +07:00
committed by GitHub
parent 7268152224
commit 32c7f9476d
4 changed files with 41 additions and 3 deletions

View File

@@ -194,4 +194,29 @@ class GenHistoryQueryTest extends BaseTestCase {
$this->assertSame( 20, \PRAutoBlogger_Gen_History_Query::PAGE_SIZE );
$this->assertSame( 100, \PRAutoBlogger_Gen_History_Query::PAGE_SIZE_MAX );
}
// -----------------------------------------------------------------------
// get_page() early return
// -----------------------------------------------------------------------
/**
* When $wpdb is null, get_page() returns the empty guard shape immediately.
*
* @return void
*/
public function test_get_page_returns_empty_when_wpdb_null(): void {
// Force the global to null to exercise the guard at the top of get_page().
$prev_wpdb = $GLOBALS['wpdb'] ?? null;
$GLOBALS['wpdb'] = null;
try {
$query = new \PRAutoBlogger_Gen_History_Query();
$result = $query->get_page();
} finally {
// Always restore so later tests are unaffected.
$GLOBALS['wpdb'] = $prev_wpdb;
}
$this->assertSame( array( 'rows' => array(), 'total' => 0 ), $result );
}
}