Skip to content

test(installer): cover required-extension helpers (stacked on #62)#63

Merged
mambax7 merged 3 commits into
XOOPS:masterfrom
mambax7:test/installer-required-extensions
May 15, 2026
Merged

test(installer): cover required-extension helpers (stacked on #62)#63
mambax7 merged 3 commits into
XOOPS:masterfrom
mambax7:test/installer-required-extensions

Conversation

@mambax7
Copy link
Copy Markdown
Contributor

@mambax7 mambax7 commented May 15, 2026

Summary

Adds unit coverage for the pure installer helpers introduced in #62, addressing the Codecov patch-coverage gap on that PR.

  • xoInstallerExtensionAvailable() — loaded vs. unknown extension; optional symbol list (all present / one missing); verifies a class-symbol probe does not trigger the autoloader (class_exists(.., false)).
  • xoInstallerBlockedHtml() — heading/label content and HTML escaping.

htdocs/install/include/functions.php is pure function declarations (no top-level code), so it is require_once'd directly; installer language constants are stub-defined in setUp().

⚠️ Stacked on #62 — read before reviewing the diff

This branch is cut from fix/installer-required-extensions-gate (#62), not from master. Consequently:

Merge order

  1. Merge Fix/installer required extensions gate #62 first.
  2. Rebase this branch onto master — the diff then collapses to the single test file, and stale Fix/installer required extensions gate #62-inherited review threads disappear.
  3. Merge this. (A xoInstallerMissingRequired() test will be added during that rebase to cover the helper Fix/installer required extensions gate #62 added after this branch was cut.)

codecov/project is the only red check; it is the known non-blocking project-wide threshold and is expected to clear once the rebase removes #62's inherited production diff from this PR's coverage delta.

Verification

PHPUnit is not installable in the dev environment (CI-only toolchain), so each assertion was independently validated with an equivalent plain-PHP harness against the #62 code (all checks pass); the test file lints clean. CI on this branch additionally runs the real PHPUnit suite green.

Copilot AI review requested due to automatic review settings May 15, 2026 10:46
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Warning

Rate limit exceeded

@mambax7 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 24 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c2786770-a0f0-46a8-8323-73fb0cf29087

📥 Commits

Reviewing files that changed from the base of the PR and between 8c998a3 and 0a474f0.

📒 Files selected for processing (1)
  • tests/unit/htdocs/install/InstallerRequiredExtensionsTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 18.13%. Comparing base (1ce8820) to head (0a474f0).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #63   +/-   ##
=========================================
  Coverage     18.12%   18.13%           
  Complexity     7854     7854           
=========================================
  Files           666      666           
  Lines         43136    43208   +72     
=========================================
+ Hits           7820     7837   +17     
- Misses        35316    35371   +55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds installer required-extension gating (stacked on #62) and introduces PHPUnit coverage for the two helper functions used to detect missing required extensions and render the “blocked install” alert.

Changes:

  • Adds InstallerRequiredExtensionsTest to cover xoInstallerExtensionAvailable() and xoInstallerBlockedHtml().
  • Adds/uses a required-extensions config list to block progression when mandatory PHP extensions/symbols are missing, including server-side guards on DB pages.
  • Adds installer language constants documenting the “missing required extensions” message (and records the change in docs/lang_diff.txt).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/htdocs/install/InstallerRequiredExtensionsTest.php New unit tests covering required-extension probing and blocked-alert HTML/escaping behavior.
htdocs/install/page_modcheck.php Collects missing required extensions, shows a danger alert, and sets a $blockNext flag; aligns MySQLi row with the configured symbol list.
htdocs/install/page_dbsettings.php Fails closed early (renders blocked alert) if MySQLi is not available before using any mysqli_* APIs.
htdocs/install/page_dbconnection.php Same MySQLi fail-closed guard before attempting DB connection logic.
htdocs/install/language/english/install.php Adds MISSING_REQUIRED_EXTENSIONS / _MSG language constants used by the installer UI.
htdocs/install/include/install_tpl.php Disables the “Next” button when $blockNext is set.
htdocs/install/include/functions.php Adds xoInstallerExtensionAvailable() and xoInstallerBlockedHtml() helper functions.
htdocs/install/include/config.php Defines $configs['extensions_required'] with required extensions and required symbol lists (e.g., MySQLi partial-build detection).
docs/lang_diff.txt Documents the new installer language defines.

Comment on lines +94 to +96
// The extension is missing, so the function short-circuits on
// extension_loaded() before any symbol probe — and even when it
// does probe, class_exists(.., false) must not autoload.
mambax7 added a commit to mambax7/XoopsCore27 that referenced this pull request May 15, 2026
Copilot review on XOOPS#63: the comment claimed the call short-circuits on
extension_loaded(), but json is loaded — the function reaches the symbol
loop and the point is that class_exists(.., false) probes the missing
class without invoking a registered autoloader. Comment-only change.
@mambax7 mambax7 requested a review from Copilot May 15, 2026 11:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread htdocs/install/include/config.php Outdated
Comment on lines +81 to +86
// Keyed by extension name; value is the human-readable label shown on the
// requirements page. mysqli has no fallback driver, so a missing entry here
// would otherwise fatal later in the DB-connection step; the others are core
// extensions with no polyfill. mbstring is intentionally NOT listed: the
// installer autoloads symfony/polyfill-mbstring (via common.inc.php), so the
// mb_* functions remain available even without the extension — gating on
Comment on lines +259 to +263
/**
* Whether a mandatory extension is usable.
*
* For extensions with no fallback driver (e.g. mysqli) a plain
* extension_loaded() is enough, but a partial/unusual build can report the
mambax7 added 3 commits May 15, 2026 08:28
Unit tests for the two pure helpers added in XOOPS#62:

- xoInstallerExtensionAvailable(): loaded/unknown extension, optional
  symbol list (all present, one missing), and that a class-symbol probe
  does not trigger the autoloader (class_exists(.., false)).
- xoInstallerBlockedHtml(): heading/label content and HTML escaping of
  the label.

functions.php is pure declarations so it is required once directly;
installer language constants are stub-defined in setUp().
Copilot review on XOOPS#63: the comment claimed the call short-circuits on
extension_loaded(), but json is loaded — the function reaches the symbol
loop and the point is that class_exists(.., false) probes the missing
class without invoking a registered autoloader. Comment-only change.
XOOPS#62 is merged; this branch is now rebased onto master so the diff is
test-only. Extend the suite to cover the helper XOOPS#62 added after this
branch was originally cut: empty when all present, reports absent
extensions, honours the per-extension symbol list, and preserves config
order. Uses a real XoopsInstallWizard (required by the parameter type
hint; class is guard-free and constructor-free).
@mambax7 mambax7 force-pushed the test/installer-required-extensions branch from f7e9c6f to 0a474f0 Compare May 15, 2026 12:31
@sonarqubecloud
Copy link
Copy Markdown

@mambax7 mambax7 requested a review from Copilot May 15, 2026 12:38
@mambax7 mambax7 merged commit d6270ed into XOOPS:master May 15, 2026
12 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

$probe = static function ($class) use (&$autoloadHits) {
$autoloadHits[] = $class;
};
spl_autoload_register($probe);
@mambax7 mambax7 deleted the test/installer-required-extensions branch May 15, 2026 12:54
mambax7 added a commit that referenced this pull request May 15, 2026
Add Installer and Tests subsections under 2.7.0 Final for the work
merged today:

- #60 guard optional function calls that fatal on PHP 8.2
  (mysqli_get_client_info(), Protector config cache)
- #62 block install with a clear message when a mandatory PHP
  extension is missing, plus full required-extension guards on the
  DB steps
- #63 unit coverage for the installer required-extension helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants