Repository navigation
test: add Unit/Integration coverage for setup.php lifecycle functions - #24
Merged
Merged
Conversation
This plugin already had strong Security coverage (auth guards, output escaping, prepared-statement migration regression tests, redirect safety) but no coverage at all for setup.php's own lifecycle functions: plugin_quicktree_install/version/uninstall/check_config/ upgrade, quicktree_check_upgrade, quicktree_setup_table, quicktree_config_settings/config_arrays, and quicktree_page_location. Added: - tests/Unit/QuicktreeVersionTest.php - tests/Unit/QuicktreeLifecycleTest.php (uninstall/check_config/upgrade) - tests/Unit/QuicktreeCheckUpgradeTest.php (page-guard, no-drift, and version-drift branches, including the plugin_config UPDATE) - tests/Unit/QuicktreeSetupTableTest.php (page-style default clamping) - tests/Unit/QuicktreeConfigSettingsAndArraysTest.php (settings merge vs. fresh-array branches, console-menu-entry gating) - tests/Unit/QuicktreePageLocationTest.php (all branch combinations) - tests/Integration/QuicktreeInstallHooksTest.php (verifies every hook and the realm plugin_quicktree_install() registers, together with its table/config-option provisioning, end-to-end) Bootstrap additions needed for the above (tests/bootstrap-unit.php): - api_plugin_register_hook/api_plugin_register_realm now log calls into $GLOBALS['__test_registered_hooks']/['__test_registered_realms'] instead of not existing at all. - read_config_option/set_config_option now share a real backing store ($GLOBALS['__test_config_options']) instead of being hardcoded to a blank read / no-op write. Verified no existing test relied on the old hardcoded behavior before making this change. - db_fetch_cell_prepared now logs its calls and returns a settable fixture value (quicktree_test_set_db_fetch_cell_prepared_return()) instead of an unconditional empty string, needed to exercise quicktree_check_upgrade()'s version-drift branch. Also fixed a stale tests/.cacti-version pin (1.2.31 -> 1.2.x) that made every local/CI run fail its own bootstrap version-match guard against a newer Cacti checkout. Intentionally not covered: quicktree_show_tab(), quicktree_graph_buttons(), quicktree_page_head() - all three are print-heavy UI functions gated by api_user_realm_auth() against a real HTTP request context, consistent with the same category of functions skipped in other plugins' suites. Verified via a real WSL Cacti install: 58 passed (192 assertions), up from 38 passed (133 assertions).
TheWitness
requested review from
bmfmancini and
xmacan
and
a lite review from Copilot
and removed request for
Copilot
September 22, 2026 11:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This plugin already had strong Security coverage (auth guards, output escaping, prepared-statement migration regression tests, redirect safety), but no coverage at all for setup.php's own lifecycle functions. This PR closes that gap.
Test coverage added
plugin_quicktree_version(),plugin_quicktree_uninstall()/check_config()/upgrade(),quicktree_check_upgrade()(page-guard, no-drift, and version-drift branches - including theplugin_configUPDATE and re-enabling thepage_headhook),quicktree_setup_table()(page-style default clamping for unset/out-of-range/valid stored values),quicktree_config_settings()/quicktree_config_arrays()(settings-merge vs. fresh-array branches, console-menu-entry gating on page style), andquicktree_page_location()(all branch combinations).plugin_quicktree_install()- verifies every one of its 8 hooks and its realm are actually registered, together with the table/config-option it provisions, in a single end-to-end pass.Bootstrap changes (
tests/bootstrap-unit.php)api_plugin_register_hook/api_plugin_register_realmnow exist and log calls (they weren't stubbed at all before).read_config_option/set_config_optionnow share a real backing store instead of being hardcoded to a blank read / no-op write. Verified no existing test relied on the old hardcoded behavior before making this change.db_fetch_cell_preparednow logs its calls and returns a settable fixture value instead of an unconditional empty string, needed to exercisequicktree_check_upgrade()'s version-drift branch.Other fix
tests/.cacti-versionwas pinned to a stale exact release (1.2.31), which made every local/CI run fail its own bootstrap version-match guard against a newer Cacti checkout. Corrected to1.2.x, matching what the CI workflow already expects.Intentionally not covered
quicktree_show_tab(),quicktree_graph_buttons(),quicktree_page_head()- all three are print-heavy UI functions gated byapi_user_realm_auth()against a real HTTP request context, consistent with the same category of functions skipped in other plugins' suites.Result
Verified via a real WSL Cacti install:
(up from 38 passed / 133 assertions before this PR)