Repository navigation
test: raise the coverage to 97.7 % - #14
Merged
Merged
Conversation
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.
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 isdevelop, which carries the harness set-up (.harness.json,tests/Arch.php, Rector) thatmaindoes 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.phpdefines reduced WordPress classes (WP_Dependencies,WP_Error,WP_Block_Type_Registry...), each guarded byclass_exists. Functions mocked by Brain Monkey stay defined for the whole process and make a collector fail silently inside itstry/catch, so the feature tests that collect stub those functions explicitly.Not covered: the admin branch of
DebugbarServiceProvider(needs theWP_ADMINconstant, which cannot be removed), thefunction_exists('add_action')guards (always true under Brain Monkey),header()andheaders_sent()inWordPressExitResponder, the 501 answer ofDoctorController(Doctor is installed),WP_CONTENT_DIRdetection inPolloraCollectorandComponents, and the OPcache-dependent lines ofWpCacheCollector.Seen in the code and left as it is:
HookTimer.php:172buildsnew \ReflectionMethod($callback)from a'Class::method'string, which is deprecated in PHP 8.4 (a test reports the deprecation);ReflectionMethod::createFromMethodName()is the replacement.$decisionscache ofHookTimeris 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.jsongoes 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) andtests/Arch.phpare clean.