Commit Graph

3 Commits

Author SHA1 Message Date
peptiderepo
73c1b878c2 style: declare(strict_types=1) on PSA_Upgrade to match project pattern
QA caught this on 37aa0c8 — every other includes/class-psa-*.php in the
codebase declares strict_types at the top. The new class should match.

Agent-Session: cowork-qa-p1-fixes-20260414
2026-04-14 20:00:12 +07:00
peptiderepo
37aa0c83f3 fix: add typed params + return types on PSA_Upgrade public methods
QA caught this on d69f637 — AGENT-OPERATING-STANDARD.md §2 requires
typed params and return types on every new public method. PHP 7.4+
supports both. Matches the pattern of other includes/ classes.

- PSA_Upgrade::is_needed( string, string ): bool
- PSA_Upgrade::maybe_run(): void

Agent-Session: cowork-qa-p1-fixes-20260414
2026-04-14 19:56:40 +07:00
peptiderepo
d69f637b06 refactor: extract upgrade logic to PSA_Upgrade class (fixes CI)
CI on 61cf00c failed PHPUnit with "Call to undefined function
plugin_dir_path()" — the test required peptide-search-ai.php, which calls
plugin_dir_path() at top level (line 19) before any hook. Stubbing every
top-level WP function the plugin file touches was the wrong shape of fix.

Proper fix: move the upgrade logic into includes/class-psa-upgrade.php so
the test can require just the helper class, matching the pattern every
other includes/ module follows.

- New: includes/class-psa-upgrade.php with PSA_Upgrade::is_needed()
  (pure) and PSA_Upgrade::maybe_run() (driver). OPTION_NAME and
  DEFAULT_STORED_VERSION exposed as constants.
- peptide-search-ai.php: psa_admin_init() now calls PSA_Upgrade::maybe_run();
  the inline helper functions and docblocks are removed.
- tests/bootstrap.php: loads class-psa-upgrade.php alongside the other
  tested classes.
- tests/unit/UpgradeTest.php: rewritten against PSA_Upgrade; adds two
  extra assertions on the constants for stability.
- ARCHITECTURE.md: refreshed to reference the class and its constants.

No behavioral change. The cost-tracker schema upgrade still runs once per
admin_init when PSA_VERSION advances past psa_db_version.

Agent-Session: cowork-qa-p1-fixes-20260414
2026-04-14 19:54:23 +07:00