test: stub add_action/add_filter so UpgradeTest can load plugin file

QA review of 88a4ae9 caught that UpgradeTest.php requires peptide-search-ai.php
(to access the pure helper psa_upgrade_needed) but did not stub add_action or
add_filter. The plugin file calls those at top level (lines 47, 53, 146, 265),
so the test would fatal on load with "Call to undefined function add_action".

Follows the stub pattern used in PostTypeTest.php.

Agent-Session: cowork-qa-p1-fixes-20260414
This commit is contained in:
peptiderepo
2026-04-14 19:12:15 +07:00
parent 88a4ae9a4e
commit 61cf00c322

View File

@@ -13,6 +13,14 @@ declare( strict_types=1 );
use PHPUnit\Framework\TestCase;
// Stub WP hook registrars so requiring the plugin file does not explode.
// The plugin bootstraps itself with add_action() / register_*_hook() calls at
// top level; these must be no-ops in the test context.
if ( ! function_exists( 'add_action' ) ) {
function add_action() {}
}
if ( ! function_exists( 'add_filter' ) ) {
function add_filter() {}
}
if ( ! function_exists( 'add_shortcode' ) ) {
function add_shortcode() {}
}