Improve Yoast SEO integration coverage; drop obsolete fixHomeBreadcrumbs - #19
Merged
Conversation
…posite Add tests for previously-uncovered Yoast integration logic: Indexables::configurePageDetection including the pre_option_show_on_front workaround that makes Yoast resolve PFCPT pages (31% -> 100%); Schema CollectionPage idempotency (58% -> 100%); the WordPressSeo composite boot/registerHooks (0% -> 100%); and a fixTaxonomyBreadcrumbs guard for a non-main taxonomy.
fixHomeBreadcrumbs only ran when Yoast's get_page_type() returned 'Home_Page' for a PFCPT page. That held in Yoast ~17 (when the logic was first written, late 2021), but Yoast has since moved is_static_posts_page() onto the $wp_query->is_posts_page flag -- which Handler always sets -- and checks it before the Home_Page branch. PFCPT pages now resolve to Static_Posts_Page, so the method is unreachable on every supported Yoast. Verified against Yoast 25.9 and 27.7, with and without Polylang and with breadcrumbs-home set: all resolve to Static_Posts_Page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
============================================
+ Coverage 87.42% 90.34% +2.91%
+ Complexity 494 485 -9
============================================
Files 31 31
Lines 1336 1315 -21
============================================
+ Hits 1168 1188 +20
+ Misses 168 127 -41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Raises Yoast SEO integration coverage from ~56% to ~95%, and removes one method that became dead code as Yoast evolved.
New tests (
WordPressSeoTest)Indexables::configurePageDetection(31% → 100%) — including thepre_option_show_on_frontworkaround, the core trick that makes Yoast resolve PFCPT pages instead of the posts page.Schema(58% → 100%) — theCollectionPageidempotency branch.WordPressSeocomposite (0% → 100%) —isSupported()/registerHooks()boot.fixTaxonomyBreadcrumbsguard (current taxonomy is not the post type's main taxonomy).Removal —
Breadcrumbs::fixHomeBreadcrumbsThis method only ran when Yoast's
get_page_type()returnedHome_Pagefor a PFCPT page. That held in Yoast ~17 (when the logic was first written, late 2021), but Yoast has since movedis_static_posts_page()onto the$wp_query->is_posts_pageflag — which the plugin'sHandleralways sets — and checks it before theHome_Pagebranch. PFCPT pages now resolve toStatic_Posts_Page, so the method is unreachable.Verified against Yoast 25.9 and 27.7, with and without Polylang, and with
breadcrumbs-homeset — every combination resolves toStatic_Posts_Page. Git history preserves the method if a future Yoast ever regresses.Result
src/Integration/WordPressSeo/: Indexables / Schema / WordPressSeo at 100%, Breadcrumbs at 91% (the remaining lines are defensive early-return guards).phpcsand PHPStan clean; 12WordPressSeoTesttests pass.