Skip to content

test: raise the coverage to 97.7 % - #14

Merged
ogorzalka merged 4 commits into
developfrom
cov/debugbar
Nov 14, 2026
Merged

ogorzalka merged 4 commits into
developfrom
cov/debugbar

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Raises the coverage of the package from 74.4 % to 97.7 % (measured locally with PHP 8.4 and pcov; the recorded ratchet was 74.41), with tests only (src/ is untouched). The base is develop, which carries the harness set-up (.harness.json, tests/Arch.php, Rector) that main does not have yet.

125 tests (98 to 223) in 18 files: the web service provider, WordPressExitResponder, the WordPress assets with Vite, the collectors (metadata, the Pollora collector parts, assets, blocks, cache and languages), the hook timer and the recorders edges, and more cases in seven existing files (ActivationTest, AdminBarRendererTest, CollectorRegistrarTest, MessageBridgeTest, WpHooksCollectorTest, RecordersTest, ComponentsTest); none is weakened. tests/Fixtures/wordpress.php defines reduced WordPress classes (WP_Dependencies, WP_Error, WP_Block_Type_Registry...), each guarded by class_exists. Functions mocked by Brain Monkey stay defined for the whole process and make a collector fail silently inside its try/catch, so the feature tests that collect stub those functions explicitly.

Not covered: the admin branch of DebugbarServiceProvider (needs the WP_ADMIN constant, which cannot be removed), the function_exists('add_action') guards (always true under Brain Monkey), header() and headers_sent() in WordPressExitResponder, the 501 answer of DoctorController (Doctor is installed), WP_CONTENT_DIR detection in PolloraCollector and Components, and the OPcache-dependent lines of WpCacheCollector.

Seen in the code and left as it is:

  • HookTimer.php:172 builds new \ReflectionMethod($callback) from a 'Class::method' string, which is deprecated in PHP 8.4 (a test reports the deprecation); ReflectionMethod::createFromMethodName() is the replacement.
  • The $decisions cache of HookTimer is keyed by the WordPress callback id alone: with the same id on two hooks (an artificial case, checked), the decision of the first is reused for the second. Real ids are unique, so it is probably harmless.

The ratchet in .harness.json goes from 74.41 to 97. The 225 tests pass in random orders and in a Linux container (php:8.4-cli); Pint, PHPStan (level 6), Rector (--dry-run) and tests/Arch.php are clean.

@ogorzalka
ogorzalka merged commit 8d8a179 into develop Nov 14, 2026
13 checks passed
@ogorzalka
ogorzalka deleted the cov/debugbar branch November 14, 2026 14:03
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.

1 participant