From 61cf00c322fedfbb8cc10b9552d47e495607c1b1 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Tue, 14 Apr 2026 19:12:15 +0700 Subject: [PATCH] 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 --- tests/unit/UpgradeTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit/UpgradeTest.php b/tests/unit/UpgradeTest.php index 7219e34..c6686f2 100644 --- a/tests/unit/UpgradeTest.php +++ b/tests/unit/UpgradeTest.php @@ -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() {} }