-
Notifications
You must be signed in to change notification settings - Fork 13
test: expand Unit coverage for plugin lifecycle, navigation, and menu setup #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+159
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?php | ||
| /* | ||
| +-------------------------------------------------------------------------+ | ||
| | Copyright (C) 2004-2026 The Cacti Group | | ||
| +-------------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
| /* | ||
| * Unit coverage for flowview_config_arrays() in setup.php - wires up the | ||
| * plugin's menu entries. It also calls plugin_flowview_check_upgrade() at | ||
| * the end, so PHP_SELF is set to a page outside that function's guard | ||
| * list to keep it from touching lib/poller.php or the flowview database | ||
| * connection. | ||
| */ | ||
|
|
||
| beforeAll(function () { | ||
| require_once __DIR__ . '/../../setup.php'; | ||
| }); | ||
|
|
||
| beforeEach(function () { | ||
| plugin_test_reset(); | ||
| $_SERVER['PHP_SELF'] = '/graphs.php'; | ||
| $GLOBALS['menu'] = array('Import/Export' => array()); | ||
| }); | ||
|
|
||
| it('adds the FlowView menu entries under Import/Export', function () { | ||
| global $menu; | ||
|
|
||
| flowview_config_arrays(); | ||
|
|
||
| expect($menu)->toHaveKey('FlowView'); | ||
| expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_devices.php'); | ||
| expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_filters.php'); | ||
| expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_schedules.php'); | ||
| expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_databases.php'); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?php | ||
| /* | ||
| +-------------------------------------------------------------------------+ | ||
| | Copyright (C) 2004-2026 The Cacti Group | | ||
| +-------------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
| /* | ||
| * Unit coverage for the plugin lifecycle contract functions in setup.php: | ||
| * plugin_flowview_check_config(), plugin_flowview_upgrade(), and | ||
| * plugin_flowview_check_upgrade()'s page-guard. | ||
| * | ||
| * plugin_flowview_check_upgrade() include_once()s Cacti core's real | ||
| * lib/poller.php and calls flowview_connect() (a real database connection | ||
| * routine) once its page guard passes, so only the guarded (skipped) | ||
| * path is exercised here - the same constraint documented for other | ||
| * plugins' poller_bottom-style functions in this fleet. | ||
| */ | ||
|
|
||
| beforeAll(function () { | ||
| require_once __DIR__ . '/../../setup.php'; | ||
| }); | ||
|
|
||
| beforeEach(function () { | ||
| plugin_test_reset(); | ||
| $_SERVER['PHP_SELF'] = '/graphs.php'; | ||
| }); | ||
|
|
||
| it('reports invalid config and raises a message when no config file exists', function () { | ||
| expect(plugin_flowview_check_config())->toBeFalse(); | ||
| expect($GLOBALS['__test_messages'])->not->toBeEmpty(); | ||
| expect($GLOBALS['__test_messages'][0][0])->toBe('flowview_info'); | ||
| }); | ||
|
|
||
| it('always reports no upgrade pending', function () { | ||
| expect(plugin_flowview_upgrade())->toBeFalse(); | ||
| }); | ||
|
|
||
| it('skips the upgrade check on pages that do not need it', function () { | ||
| plugin_flowview_check_upgrade(); | ||
|
|
||
| expect($GLOBALS['__test_db_calls'])->toBeEmpty(); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?php | ||
| /* | ||
| +-------------------------------------------------------------------------+ | ||
| | Copyright (C) 2004-2026 The Cacti Group | | ||
| +-------------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
| /* | ||
| * Unit coverage for flowview_draw_navigation_text() in setup.php. | ||
| */ | ||
|
|
||
| beforeAll(function () { | ||
| require_once __DIR__ . '/../../setup.php'; | ||
| }); | ||
|
|
||
| it('adds the flowview breadcrumb entries without disturbing existing ones', function () { | ||
| $nav = flowview_draw_navigation_text(array('other.php:' => array('title' => 'Other'))); | ||
|
|
||
| expect($nav)->toHaveKey('other.php:'); | ||
|
|
||
| foreach (array('flowview.php:', 'flowview.php:view', 'flowview_devices.php:', 'flowview_schedules.php:', 'flowview_filters.php:') as $key) { | ||
| expect($nav)->toHaveKey($key); | ||
| } | ||
|
|
||
| expect($nav['flowview_devices.php:edit']['mapping'])->toBe('index.php:,flowview_devices.php:'); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
| /* | ||
| +-------------------------------------------------------------------------+ | ||
| | Copyright (C) 2004-2026 The Cacti Group | | ||
| +-------------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
| /* | ||
| * Unit coverage for plugin_flowview_version() in setup.php. | ||
| */ | ||
|
|
||
| beforeAll(function () { | ||
| require_once __DIR__ . '/../../setup.php'; | ||
| }); | ||
|
|
||
| it('parses the plugin INFO file into an info array', function () { | ||
| $info = plugin_flowview_version(); | ||
|
|
||
| expect($info)->toBeArray(); | ||
| expect($info)->toHaveKey('name'); | ||
| expect($info)->toHaveKey('version'); | ||
| expect($info['name'])->toBe('flowview'); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.