Improve test coverage to 100% and raise Infection thresholds - #11
Merged
Conversation
Line coverage goes from 90% to 100% and the mutation score (MSI) from 74% to 94%; the Infection thresholds are raised from 61.74/76.77 to 90/90 to lock the gains in. Tests only, no changes to src/: - ClientExceptionTest (new): all three factories with exact messages, including subcode and the user facing title/message variants - FbTest (new): DateTimeInterface creation time, founding date/future bounds, subdomain index validation and immutability - ClientTest: injected request/stream factories (one request per pixel) and HTTP client auto discovery through a test DiscoveryStrategy - ErrorResponseTest: data provider covering missing required fields and a wrong type for every field - FbqGeneratorTest: JSON encode failure logs an error and returns '' - EventTest/ContentTest/CustomTest: default event id/time, the standard event list, invalid action_source/delivery_category, full Custom payload, unsupported values - TestLogger moved to tests/TestLogger.php so it can be shared
5 tasks
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.
Summary
Tests only — no changes to
src/.tests/Exception/ClientExceptionTest.php(new) —ClientExceptionwas 0% covered: all three factories, exact messages incl. subcode and user-facing title/message variants, previous exception.tests/ValueObject/FbTest.php(new) — the abstractFbbase viaFbp:DateTimeInterfacecreation time, founding-date/future bounds, subdomain-index validation and immutability, defaults.ClientTest—setRequestFactory/setStreamFactory(one request per pixel with the pixel's own token) and HTTP-client auto-discovery when nothing is injected, using a testDiscoveryStrategyprepended toPsr18ClientDiscovery(restored infinally, no network).ErrorResponseTest— the three negative tests consolidated into one data provider covering 16 malformed responses (missing required fields plus a wrong type for every field).FbqGeneratorTest— JSON-encode failure logs an error and returns''.EventTest/ContentTest/CustomTest— default event id/time, the standard-event list, invalidaction_source/delivery_categoryrejection, fullCustompayload, unsupported value rejection.tests/TestLogger.php— moved out ofClientTest.phpsoFbqGeneratorTestcan share it.infection.json.dist— thresholds raised 61.74 → 90 (MSI) and 76.77 → 90 (covered MSI);CLAUDE.mdupdated to match.The 14 remaining escaped mutants are either untestable (
random_intbounds,ceilvsflooronmicrotime, JSON depth 512,time() + 1upper bound) or a pcov attribution artifact (tests whose frames in a file are all unwound by an exception get no line attribution there, so Infection doesn't select them — verified by applying theParameters.php:96mutant by hand).Test plan
vendor/bin/phpunit— 80 tests, 100% line coveragevendor/bin/phpstan analyse(level max, incl. tests)vendor/bin/ecs checkvendor/bin/composer-dependency-analyser,composer normalize --dry-runvendor/bin/infection— MSI 94%, passes the raised thresholds--prefer-lowest