refactor: extract intropage_device_scope() and add a coverage harness - #378
Closed
somethingwithproof wants to merge 1 commit into
Closed
somethingwithproof wants to merge 1 commit into
somethingwithproof wants to merge 1 commit into
Conversation
Extract the repeated get_simple_device_perms + intropage_get_allowed_devices preamble into one documented helper returning the user's device scope, and adopt it in alert.php's two panels. Add a phpunit.xml coverage source config and a behavioural Pest test (with permission-chain stubs) that exercises every branch of the helper, since the plugin previously had only source-scan tests and no coverage config. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
This was referenced Aug 30, 2026
Member
Author
|
Folded into #379, which already contains this commit — the two are stacked, not siblings ( Reviewing them separately means reviewing the helper twice. #379 carries both commits: adding |
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.
First increment of the panel de-duplication, plus the test infrastructure it needs.
Helper
The device-permission preamble (
get_simple_device_permsthen, for non-simple users,intropage_get_allowed_devices) is copied ~39 times across the panels. This adds one documentedintropage_device_scope($user_id)returning{simple, allowed}and adopts it in the twoalert.phppanels (an 8-line block becomes 4, behaviour identical). It returns only the uniform parts: the IN() clause is left to the caller because the column and anyANDprefix differ between panels (for examplealert.phpusesAND host.id IN (...)).Coverage harness
The plugin had no coverage configuration, and its
tests/Security/*are source-pattern scans rather than behavioural tests. This adds aphpunit.xmlwith a coverage source list so coverage is measurable, plustests/Unit/DeviceScopeTest.phpand permission-chain stubs intests/bootstrap.php. The test drives every branch of the helper (all pass under PHP 8.4).Note: five
tests/Security/*cases already fail ondevelop(verified by stashing this change); they are pre-existing and untouched here.This is deliberately one family. The remaining ~37 sites want per-site verification of each IN()-clause variant, done family by family, not a blind sweep.
Closes #384