test: expand Unit coverage for plugin lifecycle, navigation, and menu setup - #270
Open
TheWitness wants to merge 1 commit into
Open
TheWitness wants to merge 1 commit into
TheWitness wants to merge 1 commit into
Conversation
… setup This plugin already had extensive Security/Unit coverage (auth guards, output escaping, prepared-statement migration, listener port/command security, query building, core formatting helpers). The gap was setup.php's plugin-lifecycle functions, which were only checked for static existence. Closed the safely-testable part of that gap: - plugin_flowview_version() - plugin_flowview_check_config() (the no-config-file branch, which is the only one reachable without a configured Flowview database) - plugin_flowview_upgrade() and plugin_flowview_check_upgrade()'s page-guard - flowview_draw_navigation_text() - flowview_config_arrays() (menu registration under Import/Export) Intentionally left uncovered: plugin_flowview_install(), plugin_flowview_uninstall(), flowview_setup_table(), and flowview_drop_table() all unconditionally call flowview_connect(), which performs a real database connection (or a fatal exit() on failure) and, via plugin_flowview_check_upgrade(), can include_once() Cacti core's real lib/poller.php - the same unconditionally-declared-core-function hazard documented for other plugins' poller_bottom-style functions in this fleet. Those functions are not safely testable without a real Flowview database. No new unserialize() hardening was needed: every unserialize() call in this plugin already goes through sanitize_unserialize_selected_items() or an explicit allowed_classes => false (including in the vendored Net\DNS2 library). tests/bootstrap-unit.php gained api_plugin_register_hook/ api_plugin_register_realm call-logging stubs (the existing plugin_test_reset/plugin_test_queue_db_result/plugin_test_db_result fixture convention was reused as-is). Verified via a real WSL Cacti install (composer-managed Pest, not a plugin-local vendor tree): 77 passed (1200 assertions), up from 71.
TheWitness
requested review from
bmfmancini and
xmacan
and
a lite review from Copilot
September 22, 2026 03:45
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Reset registration logs between tests and add the required CHANGELOG.md entry.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Expands FlowView unit coverage for lifecycle, navigation, version parsing, and menu setup.
Changes:
- Adds four focused unit-test files.
- Adds hook and realm registration logging stubs to the test bootstrap.
| File | Summary |
|---|---|
tests/Unit/FlowviewVersionTest.php |
Tests plugin metadata parsing. |
tests/Unit/FlowviewNavigationTest.php |
Tests navigation entries. |
tests/Unit/FlowviewLifecycleTest.php |
Tests lifecycle guard behavior. |
tests/Unit/FlowviewConfigArraysTest.php |
Tests menu registration. |
tests/bootstrap-unit.php |
Adds registration logging fixtures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
| } | ||
|
|
||
| $GLOBALS['__test_registered_hooks'] = array(); |
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.

This plugin already had extensive Security/Unit coverage (auth guards, output escaping, prepared-statement migration, listener port/command security, query building, core formatting helpers). The gap was
setup.php's plugin-lifecycle functions, which were only checked for static existence. Closed the safely-testable part of that gap, running the full suite against a real Cacti install in WSL (composer-managed Pest, not a plugin-local vendor tree) until everything passed.Added coverage
plugin_flowview_version()plugin_flowview_check_config()(the no-config-file branch, which is the only one reachable without a configured Flowview database)plugin_flowview_upgrade()andplugin_flowview_check_upgrade()'s page-guardflowview_draw_navigation_text()flowview_config_arrays()(menu registration under Import/Export)Intentionally not covered
plugin_flowview_install(),plugin_flowview_uninstall(),flowview_setup_table(), andflowview_drop_table()all unconditionally callflowview_connect(), which performs a real database connection (or a fatalexit()on failure) and, viaplugin_flowview_check_upgrade(), caninclude_once()Cacti core's reallib/poller.php— the same unconditionally-declared-core-function hazard documented for other plugins' poller_bottom-style functions in this fleet. Those functions are not safely testable without a real Flowview database.Security
No new
unserialize()hardening was needed: everyunserialize()call in this plugin already goes throughsanitize_unserialize_selected_items()or an explicitallowed_classes => false(including in the vendoredNet\DNS2library).Test infrastructure
tests/bootstrap-unit.phpgainedapi_plugin_register_hook/api_plugin_register_realmcall-logging stubs (the existingplugin_test_reset/plugin_test_queue_db_result/plugin_test_db_resultfixture convention was reused as-is).Result
Tests: 77 passed (1200 assertions), up from 71.