Repository navigation
Test suite phase 2: clock, variant corpus, and the parser bugs it found - #643
Merged
Merged
Conversation
MyAnimeList shows relative and partial dates ("Yesterday, 9:25 PM",
"5 hours ago", "Oct 13", weekdays). About 20 sites built them with
`new DateTimeImmutable($text)` or date('Y'), so results depended on the
system clock and snapshots drifted from day to day.
- Jikan\Helper\Time::parse()/now() read the time from symfony/clock
(new runtime dependency, ^7.4 || ^8.0). Default is the system clock, so
behaviour is unchanged; consumers can pin it with Clock::set().
Equivalence was checked on all 928 distinct date texts the test suite
parses: identical results to the microsecond and the same exceptions.
- Every date site goes through Time (Helper\Parser, 15 parsers, one model).
- Tests freeze the clock at 2026-10-12T12:00:00Z (JikanTest\TestCase), so
the 15 date masks and the 6 tolerance comparisons are gone and snapshots
hold exact dates.
The refreshed snapshots are in jikan-me/jikan-fixtures (feat/phase-2-corpus).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found by the new variant corpus against live recordings: - getAnimeSearch()/getMangaSearch() threw BadResponseException when a search had no matches: MyAnimeList answers those with a 404 page. They now return the empty model, as character and person search already did. - getPersonSearch() threw ParserException on no matches: MAL shows a single "No results returned" row, which PersonSearchParser now recognises. - getCharacterSearch()/getPersonSearch() caught every BadResponseException but only handled 404, so a 429 or 500 fell through to an undefined $crawler and a TypeError. They now rethrow it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test/unit/Corpus: variants.json (99 variants covering all 76 MalClient methods plus page 2s, zero results, airing/upcoming/movie/light novel, old and future seasons, a 404 and id 0), RecordedPages (serves the recorded HTTP status and sets the clock to the recording time) and CorpusTest (invariants, named snapshot, second call equal, or the expected exception). - scripts/record_variants.php records exactly what each MalClient method requests (--dry-run, --live, --only, --force; GET only, 3.5 s apart). - PHPStan baseline shrinks by the entry the search fix removed. - CHANGELOG (Added: the clock; Fixed: the searches) and PLAN.md (Phase 2 status, plus the bugs the corpus found that still need a decision). The pages and snapshots are in jikan-me/jikan-fixtures (feat/phase-2-corpus), which must merge first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The corpus and scripts/field_witness.php showed model fields that no recorded page ever filled. Checked one by one against the recorded HTML; where MyAnimeList shows the data, the parser was wrong: - Genre pagination: a positional selector (div[5]) no longer matched, so every genre list said one page. Parser::pagination() now reads div.pagination (?page=N and ?p=N, current page by class). - News, featured-article and user-update lists returned a hard-coded hasNextPage=false / lastVisiblePage=1; they now read the page. - Person published manga and the manga related-entries table expected <tr> directly under <table>; HTML5 parsing inserts <tbody>. - Anime/manga card type and manga card authors/serialization had been stubbed to null after a layout change; MAL shows them again. Seasonal cards take the type from their section header. - Top character/person kanji names moved from a span to a div. - Profile "about" is null, not "", when empty. Tests that asserted the broken values (null kanji, null seasonal type, two manga relation groups) now assert the real ones. PHPStan baseline: 429 -> 425 (dead code and a string-typed page number went away). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Anime cards on genre, producer and seasonal lists no longer show licensors on MyAnimeList (none on any recorded card page), and the getter had been stubbed to return [] since. Removed from AnimeCard (so SeasonalAnime too) and AnimeCardParser, with its test. Anime::getLicensors() from getAnime() is unchanged. Recorded under Breaking in CHANGELOG. Fields MAL left empty in the user list JSON (studios, licensors, season, magazines, is_added_to_list) are kept for now, per owner decision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- LastUpdatesParser only read "progress/total" when both were numbers, so "Reading 92/?" (total not known yet) lost the 92. Ongoing series in a profile's last anime/manga updates now keep their episode or chapter count; the total stays null. - Four corpus variants recorded for fields no page had filled: explicit genres (High School DxD), filler/recap (Naruto's episode list), music videos (Bocchi the Rock!), birthday/about/manga updates (Xinil). Music videos, recap, birthday and about are now witnessed; the manga updates exposed the progress bug above. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LastUpdatesParser passed numeric strings to BaseLastUpdate; the (int) casts in the previous commit fixed both baseline entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
irfan-dahir
changed the base branch from
v5/hardening-and-performance
to
master
October 14, 2026 09:04
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.
Phase 2 of the test plan in
PLAN.md, plus the parser bugs it found.Deterministic dates
new DateTimeImmutable($text)ordate('Y'). They now go throughJikan\Helper\Time, which uses the PSR-20 clock fromsymfony/clock(new runtime dependency).Clock::set(new MockClock(...)).Variant corpus
test/unit/Corpus/variants.json: 99 variants covering all 76MalClientmethods (previously 6 were called by tests), plus page 2s, zero-result searches, airing/upcoming/movie/light-novel/author pages, old and future seasons, a 404 and id 0.RecordedPagesserves each page with its recorded HTTP status and sets the clock to its recording time.CorpusTestruns each variant throughMalClientand checks the model invariants, a named snapshot, and that a second call builds an equal model.scripts/record_variants.php(--dry-run,--live,--only,--force) records exactly what each method requests.Bugs found and fixed
BadResponseException, because MAL returns a 404.ParserException.TypeError.hasNextPage=falsehard-coded.<tbody>:Person::publishedMangawas always empty (14 for Miyazaki now), and the manga related-entries table was skipped.typeand manga cardauthors/serializationhad been stubbed tonulland are back. Seasonal cards take their type from the section header.nameKanjiwas alwaysnull.Profile::aboutisnull, not"", when empty.Breaking
AnimeCard::getLicensors()removed (and soSeasonalAnime's). Cards no longer show licensors on MAL.Anime::getLicensors()is unchanged.The suite is at 750 tests; PHPStan baseline 429 → 424. CHANGELOG and
PLAN.mdare updated.🤖 Generated with Claude Code