Repository navigation
Test suite phase 3: missing-field variants, mutation testing, helper property tests - #644
Merged
Merged
Conversation
MissingFieldTest takes every recorded anime/manga detail page in the corpus (8 pages), removes one sidebar "Label:" row at a time through the DOM, and checks that parsing still succeeds and only the fields that row feeds change: 166 cases, no requests. It found two crashes when a row is absent: - AnimeParser::getAnimeAiredString() read the "Aired:" row without checking it exists (InvalidArgumentException from getAnime()). - MangaParser::getPublished() passed null to DateRange when there is no "Published:" row (TypeError from getManga()). Both now return the empty range MAL shows as "Not available". Without the fix the test fails 8 times; with it, all 166 pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Infection makes small deliberate changes to src/Parser and src/Helper (flip a condition, drop a line, return early) and runs the tests against each; a change no test notices marks code that runs but is not checked. - infection.json5: mutates src/Parser and src/Helper with the default mutators; text, summary and HTML reports under build/infection. - .github/workflows/mutation.yaml: on pull requests touching src/, only the changed lines (--git-diff-lines against the base branch), with escaped mutants as GitHub annotations; nightly and on demand, everything, with the HTML report as an artifact. pcov provides coverage. continue-on-error for now: set minMsi once the nightly score is known. - infection/infection ^0.35.7 as a dev dependency. Checked locally up to the coverage step (this machine's static PHP has no coverage driver); the first real run will be in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HelperPropertiesTest checks rules over ~400 generated inputs per helper (junk text, emoji, CJK, NBSP, HTML fragments, malformed dates; fixed seed): cleanse() returns trimmed valid UTF-8, every date helper returns a date or null, the id helpers accept any text and idFromUrl() reads ids back, durations are never negative, placeholder normalisation is idempotent. It found: - parseDate() returned false (a TypeError for ?DateTimeImmutable) when text like "Unknown, 2026" matched its "Mon, YYYY" branch; it now falls through. - parseDateMDYReadable() threw on the same text; it now returns null. - stringIdFromUrl() warned on a URL without a path. Left as is and documented in the test: cleanse() is not idempotent (<br> becomes a newline, which a second pass strips); changing that would change the newlines in all scraped text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Uni
6910
code 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.
Phase 3 of the test plan in
PLAN.md.Synthetic missing-field variants
What it tests:
test/unit/Corpus/MissingFieldTest.phptakes the 8 recorded anime/manga detail pages, removes one sidebar "Label:" row at a time through the DOM (166 cases, no requests), and checks that parsing still succeeds and only that row's fields change.Two crashes found and fixed:
getAnime()failed when a page has no "Aired:" row.getManga()failed when a page has no "Published:" row.Both now return the empty range that MyAnimeList itself shows as "Not available". Without the fix, the test fails 8 times.
Mutation testing (report-only)
infection.json5and.github/workflows/mutation.yaml: Infection mutatessrc/Parserandsrc/Helperand reruns the tests.src/: only the changed lines are mutated, with escaped mutants as annotations.continue-on-errorfor now; setminMsifrom the first nightly score.Property tests for the shared helpers
test/unit/Helper/HelperPropertiesTest.phpruns about 400 generated inputs per helper (junk, emoji, CJK, NBSP, HTML fragments, malformed dates; fixed seed).parseDate()returnedfalse(aTypeError) on text like "Unknown, 2026".parseDateMDYReadable()threw on the same text.stringIdFromUrl()warned on a URL with no path.JString::cleanse()is not idempotent. Fixing it would change the newlines in all scraped text.The suite is at 926 tests. CHANGELOG and
PLAN.mdare updated.🤖 Generated with Claude Code