Repository navigation
Build/Test Tools: Remove reliance on PHPUnit annotation parsing. - #13848
Sukhendu2002 wants to merge 8 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
lancewillett
left a comment
There was a problem hiding this comment.
The compatibility aliases and caller migration look reasonable in static review. Please refresh against trunk: the patch now conflicts in dependencies/scripts.php, dependencies/styles.php, icons/wpIconsRegistry.php, and taxonomy.php. I would like to validate the reconciled harness before approval.
The recorded failed CI job stopped during environment installation waiting for port 8889, before PHPUnit; it does not establish a defect in the renamed expectations.
AI review · gpt-6
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the migration to WordPress-prefixed PHPUnit expectations.
No open issues 🎉
What changed in this PR
This PR updates WordPress’s PHPUnit infrastructure to use explicitly WordPress-prefixed deprecation and incorrect-usage expectations for Trac ticket #54029. It migrates the core test suite while retaining legacy helpers and annotations for backward compatibility.
Changes:
- Adds
expectWPDeprecated()andexpectWPIncorrectUsage(), with corresponding annotations and legacy aliases. - Separates expectation setup and assertion methods, and parses annotations through reflection.
- Migrates existing tests and adds coverage for the new helpers and legacy compatibility.
| File | Description |
|---|---|
| tests/phpunit/tests/xmlrpc/wp/getUsers.php | Prefixes user-query deprecation annotation. |
| tests/phpunit/tests/wp-token-map/wpTokenMap.php | Prefixes invalid-token usage annotation. |
| tests/phpunit/tests/widgets.php | Migrates widget incorrect-usage helpers. |
| tests/phpunit/tests/view-config.php | Migrates configuration incorrect-usage helper. |
| tests/phpunit/tests/view-config-data.php | Migrates configuration validation expectations. |
| tests/phpunit/tests/user/queryCache.php | Prefixes query-cache deprecation annotations. |
| tests/phpunit/tests/user/query.php | Prefixes author-query deprecation annotations. |
| tests/phpunit/tests/user/multisite.php | Prefixes legacy user-check annotation. |
| tests/phpunit/tests/user/mapMetaCap.php | Migrates capability incorrect-usage helper. |
| tests/phpunit/tests/user/capabilities.php | Migrates capability and role expectations. |
| tests/phpunit/tests/user.php | Migrates user API expectations. |
| tests/phpunit/tests/theme/wpThemeJson.php | Prefixes property-resolution usage annotations. |
| tests/phpunit/tests/theme/themeDir.php | Prefixes legacy theme API annotations. |
| tests/phpunit/tests/theme/support.php | Prefixes theme-support usage annotations. |
| tests/phpunit/tests/theme.php | Prefixes theme deprecation annotations. |
| tests/phpunit/tests/taxonomy.php | Prefixes taxonomy validation annotations. |
| tests/phpunit/tests/speculative-loading/wpSpeculationRules.php | Migrates speculation-rule usage helpers. |
| tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php | Prefixes sitemap rendering usage annotations. |
| tests/phpunit/tests/shortcode.php | Prefixes shortcode validation annotation. |
| tests/phpunit/tests/script-modules/wpScriptModules.php | Migrates script-module usage expectations. |
| tests/phpunit/tests/rest-api/rest-users-controller.php | Prefixes author-query deprecation annotation. |
| tests/phpunit/tests/rest-api/rest-settings-controller.php | Migrates settings registration usage helpers. |
| tests/phpunit/tests/rest-api/rest-server.php | Prefixes deprecated REST filter annotation. |
| tests/phpunit/tests/rest-api/rest-schema-validation.php | Migrates schema validation usage helpers. |
| tests/phpunit/tests/rest-api/rest-schema-sanitization.php | Migrates schema sanitization usage helpers. |
| tests/phpunit/tests/rest-api/rest-posts-controller.php | Migrates post-schema usage helpers. |
| tests/phpunit/tests/rest-api/rest-post-meta-fields.php | Migrates metadata registration usage helpers. |
| tests/phpunit/tests/rest-api/rest-comments-controller.php | Migrates capability usage expectation. |
| tests/phpunit/tests/rest-api.php | Migrates route registration usage expectations. |
| tests/phpunit/tests/query/results.php | Prefixes invalid-date usage annotation. |
| tests/phpunit/tests/query/lazyLoadCommentMeta.php | Prefixes comment-meta deprecation annotations. |
| tests/phpunit/tests/query/isSitemap.php | Prefixes premature-query usage annotation. |
| tests/phpunit/tests/query/conditionals.php | Migrates conditional-query expectations. |
| tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php | Migrates export-data usage helpers. |
| tests/phpunit/tests/post/wpDeletePost.php | Migrates invalid-post usage helper. |
| tests/phpunit/tests/post/types.php | Prefixes post-type validation annotations. |
| tests/phpunit/tests/post/truncatePostSlug.php | Prefixes slug-helper deprecation annotation. |
| tests/phpunit/tests/post/getTheExcerpt.php | Prefixes excerpt deprecation annotation. |
| tests/phpunit/tests/post/getPageByTitle.php | Prefixes page-lookup deprecation annotation. |
| tests/phpunit/tests/option/registration.php | Prefixes deprecated settings-group annotations. |
| tests/phpunit/tests/oembed/wpOembed.php | Migrates malformed-provider usage helper. |
| tests/phpunit/tests/multisite/wpGetSites.php | Prefixes legacy site-query annotations. |
| tests/phpunit/tests/multisite/site.php | Migrates deprecated blog-hook expectation. |
| tests/phpunit/tests/multisite/network.php | Prefixes dashboard-blog deprecation annotation. |
| tests/phpunit/tests/meta/registerMeta.php | Migrates metadata validation usage helpers. |
| tests/phpunit/tests/menu/nav-menu.php | Prefixes menu registration usage annotations. |
| tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php | Prefixes decoding-helper deprecation annotations. |
| tests/phpunit/tests/media.php | Migrates media API expectations. |
| tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php | Migrates Interactivity API annotations. |
| tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-style.php | Prefixes style-directive usage annotations. |
| tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-context.php | Prefixes context-directive usage annotation. |
| tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-class.php | Prefixes class-directive usage annotations. |
| tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php | Prefixes binding validation annotations. |
| tests/phpunit/tests/includes/helpers.php | Tests new helpers and legacy compatibility. |
| tests/phpunit/tests/image/size.php | Prefixes dimension-helper deprecation annotations. |
| tests/phpunit/tests/image/functions.php | Prefixes image API deprecation annotations. |
| tests/phpunit/tests/icons/wpIconsRegistry.php | Prefixes icon registry usage annotations. |
| tests/phpunit/tests/icons/wpIconCollectionsRegistry.php | Prefixes icon collection usage annotations. |
| tests/phpunit/tests/http/wpGetHttpHeaders.php | Migrates deprecated HTTP argument expectation. |
| tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php | Prefixes text-modification usage annotations. |
| tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | Prefixes tag-processor validation annotations. |
| tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php | Migrates bookmark-limit usage expectations. |
| tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php | Prefixes text-modification usage annotation. |
| tests/phpunit/tests/html-api/wpHtmlProcessor.php | Prefixes HTML processor usage annotations. |
| tests/phpunit/tests/html-api/wpHtmlProcessor-bookmark.php | Prefixes virtual-node bookmark annotation. |
| tests/phpunit/tests/general/template_CheckedSelectedHelper.php | Migrates readonly-helper deprecation expectation. |
| tests/phpunit/tests/functions/wpUniqueIdFromValues.php | Prefixes unique-ID usage annotation. |
| tests/phpunit/tests/functions/wpListUtil.php | Prefixes list utility usage annotations. |
| tests/phpunit/tests/functions/wpListPluck.php | Uses renamed expectation setup method. |
| tests/phpunit/tests/functions/wpGetAdminNotice.php | Prefixes notice validation annotation. |
| tests/phpunit/tests/functions/wpAdminNotice.php | Prefixes notice validation annotation. |
| tests/phpunit/tests/functions/getNonCachedIds.php | Migrates cache-ID validation expectations. |
| tests/phpunit/tests/formatting/wpSlash.php | Prefixes legacy escaping annotations. |
| tests/phpunit/tests/formatting/wpRicheditPre.php | Prefixes class-level deprecation annotation. |
| tests/phpunit/tests/formatting/wpHtmleditPre.php | Prefixes class-level deprecation annotation. |
| tests/phpunit/tests/formatting/likeEscape.php | Prefixes escaping deprecation annotation. |
| tests/phpunit/tests/formatting/cleanPre.php | Prefixes class-level deprecation annotation. |
| tests/phpunit/tests/fonts/font-library/wpRestFontCollectionsController.php | Migrates invalid font collection expectations. |
| tests/phpunit/tests/fonts/font-library/wpFontLibrary/registerFontCollection.php | Migrates duplicate collection usage helper. |
| tests/phpunit/tests/fonts/font-library/wpFontCollection/getData.php | Migrates font-data validation expectations. |
| tests/phpunit/tests/fonts/font-library/wpFontCollection/__construct.php | Migrates invalid font-slug expectation. |
| tests/phpunit/tests/filters.php | Prefixes deprecated filter annotations. |
| tests/phpunit/tests/dependencies/wpSanitizeScriptAttributes.php | Migrates script-attribute deprecation helpers. |
| tests/phpunit/tests/dependencies/wpRemoveSurroundingEmptyScriptTags.php | Migrates script-tag usage helper. |
| tests/phpunit/tests/dependencies/wpInlineScriptTag.php | Prefixes unsafe script-content annotation. |
| tests/phpunit/tests/dependencies/styles.php | Migrates stylesheet API expectations. |
| tests/phpunit/tests/dependencies/scripts.php | Migrates script API expectations. |
| tests/phpunit/tests/dependencies/jquery.php | Prefixes script deregistration usage annotation. |
| tests/phpunit/tests/db.php | Migrates database API expectations. |
| tests/phpunit/tests/date/query.php | Prefixes date validation usage annotations. |
| tests/phpunit/tests/customize/widgets.php | Migrates deprecated Customizer widget expectations. |
| tests/phpunit/tests/customize/partial.php | Migrates partial-rendering usage helper. |
| tests/phpunit/tests/cron.php | Prefixes cron deprecation annotation. |
| tests/phpunit/tests/connectors/wpRegisterConnector.php | Migrates unknown-connector usage helper. |
| tests/phpunit/tests/connectors/wpConnectorsResolveAiProviderLogoUrl.php | Prefixes invalid logo-path annotation. |
| tests/phpunit/tests/connectors/wpConnectorsIsApiKeyValid.php | Migrates unknown-provider usage helper. |
| tests/phpunit/tests/connectors/wpConnectorsGetConnectorScriptModuleData.php | Migrates malformed-credentials usage helpers. |
| tests/phpunit/tests/connectors/wpConnectorRegistry.php | Migrates connector registry usage helpers. |
| tests/phpunit/tests/compat/jsonEncodeDecode.php | Migrates legacy JSON deprecation expectations. |
| tests/phpunit/tests/category/getCategoryParents.php | Migrates deprecated category argument expectation. |
| tests/phpunit/tests/category/getAllCategoryIds.php | Prefixes legacy category lookup annotation. |
| tests/phpunit/tests/cache.php | Migrates cache incorrect-usage helpers. |
| tests/phpunit/tests/blocks/wpBlockTypeRegistry.php | Prefixes block-type registry annotations. |
| tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php | Prefixes block-pattern registry annotations. |
| tests/phpunit/tests/blocks/wpBlockMetadataRegistry.php | Migrates metadata collection usage helpers. |
| tests/phpunit/tests/blocks/register.php | Prefixes block registration usage annotations. |
| tests/phpunit/tests/blocks/editor.php | Prefixes deprecated editor-filter annotations. |
| tests/phpunit/tests/block-templates/WpBlockTemplatesRegistry.php | Migrates template registration usage helpers. |
| tests/phpunit/tests/block-template.php | Migrates template unregistration usage helper. |
| tests/phpunit/tests/block-template-utils.php | Prefixes template utility deprecation annotations. |
| tests/phpunit/tests/block-supports/wpCreateBlockStyleVariationInstanceName.php | Prefixes style-variation deprecation annotation. |
| tests/phpunit/tests/block-supports/typography.php | Migrates typography expectation annotations. |
| tests/phpunit/tests/block-bindings/wpBlockBindingsRegistry.php | Prefixes binding registry usage annotations. |
| tests/phpunit/tests/auth.php | Migrates referer-check usage helpers. |
| tests/phpunit/tests/ai-client/wpAiClientPromptBuilder.php | Migrates prompt-builder usage expectations. |
| tests/phpunit/tests/ai-client/wpAiClientAbilityFunctionResolver.php | Migrates missing-ability usage helpers. |
| tests/phpunit/tests/admin/wpUserSearch.php | Prefixes legacy user-search annotation. |
| tests/phpunit/tests/admin/wpListTable.php | Prefixes view-link validation annotation. |
| tests/phpunit/tests/admin/wpAutomaticUpdater.php | Prefixes directory validation annotation. |
| tests/phpunit/tests/admin/includesTheme.php | Prefixes legacy theme API annotations. |
| tests/phpunit/tests/admin/includesPlugin.php | Migrates submenu-position usage helper. |
| tests/phpunit/tests/actions.php | Prefixes deprecated action annotations. |
| tests/phpunit/tests/abilities-api/wpRegisterAbilityCategory.php | Prefixes ability-category API annotations. |
| tests/phpunit/tests/abilities-api/wpRegisterAbility.php | Migrates ability registration usage expectations. |
| tests/phpunit/tests/abilities-api/wpAbilityCategoryRegistry.php | Prefixes category registry usage annotations. |
| tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php | Prefixes abilities registry usage annotations. |
| tests/phpunit/includes/abstract-testcase.php | Adds prefixed APIs, annotation parsing, and compatibility wrappers. |
Review effort: Balanced
…pectations # Conflicts: # tests/phpunit/tests/dependencies/scripts.php # tests/phpunit/tests/dependencies/styles.php # tests/phpunit/tests/icons/wpIconsRegistry.php
lancewillett
left a comment
There was a problem hiding this comment.
Thanks for the refresh, @Sukhendu2002. At f60de2a the earlier conflicts are resolved and CI is green. I ran a probe class against trunk and against this head.
- Matches trunk: legacy
@expectedDeprecatedand@expectedIncorrectUsagemethod annotations behave the same. Class-level annotations on a parent class are not read on either. - Regression: a subclass that overrides
expectDeprecated()orexpectedDeprecated()is silently skipped.set_up()now callsset_up_deprecation_expectations()andassert_post_conditions()now callsassert_expected_deprecations(), so the overrides never run. In the probe, trunk logs["expectDeprecated","expectedDeprecated"]and this head logs[]. Plugin suites that extendWP_UnitTestCaseand customize those methods would lose their behavior without any error.
Could the two lifecycle calls go through the existing public methods, which then delegate to the new ones? Or could the new methods detect an override? Either way, an override written against the current API would keep running.
AI review · claude-opus-5-5
|
Thanks for the probe! Fixed: |
lancewillett
left a comment
There was a problem hiding this comment.
Approving at dbf9288. Thank you: 0299747 fixes the override issue. set_up() and assert_post_conditions() call expectDeprecated() and expectedDeprecated() again, and those forward to the new methods, so subclass overrides run just as they do on trunk.
- Exact head:
legacyDeprecationOverrides.phpandadminbar.phppass in single site and multisite (random order), and PHPCS is clean onabstract-testcase.phpand the new test. - Mutation testing: the new test fails if
set_up()bypassesexpectDeprecated(), ifassert_post_conditions()bypassesexpectedDeprecated(), or ifexpectDeprecated()stops forwarding. - Trunk merge (dbf9288): the only hand-resolved hunk is in
adminbar.php. It keeps trunk's renamedtest_unregistered_icon_renders_no_icon_element()with this PR's@expectedWPIncorrectUsageannotation, which is correct.
Optional, and not a regression: nothing fails if expectedDeprecated() stops forwarding to assert_expected_deprecations(). The same no-op passes all of Tests_TestHelpers on trunk too. A case in the new test where an expected deprecation never fires, asserting that the override path still reports it, would close that gap.
Still waiting on dmsnell's requested review.
AI review · claude-opus-5-5
|
@Sukhendu2002 this now conflicts with trunk in AI review · |
|
Merged trunk and resolved the conflict. Also updated the new tests from trunk to use the new names. Ready for another look. |
|
@Sukhendu2002 thanks. I compared 2cdaacb against the head I approved, dbf9288. The only changes are the renames in tests that landed in trunk since then, and CI is green. It conflicts again, though. r65343 (Interactivity API) landed at 08:57 UTC today and adds three Since the old method names still work, you don't need to chase every new test from trunk. Resolve that one file, and leave the new calls as they are if that's simpler. A follow-up can rename stragglers after this lands. That keeps the merges small while this waits on @dmsnell's review. AI review · |
…pectations # Conflicts: # tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-html.php
|
@Sukhendu2002 thanks. 4880f6a merges cleanly, and CI is green. Your changes match 2cdaacb apart from the conflict resolution in AI review · |
|
@lancewillett thanks for the ping: what kind of ways could I be helpful in review here? are there specific things you want me to consider? |
|
Thanks, @dmsnell. I requested your review because this touches HTML API tests, but I was overly broad in treating it as a landing requirement. Those edits only rename the incorrect-usage annotations and helper call; the test cases and assertions stay unchanged. We’ve reviewed the shared harness changes and verified the backward-compatibility fix. I don’t have a specific HTML API concern to ask you to resolve, so please consider this an optional heads-up rather than a blocking review request. |
dmsnell
left a comment
There was a problem hiding this comment.
Thanks for clarifying @lancewillett — I have no strong objections to this so I’ll leave my approval as a way to prevent blocking it.
There’s a part of me that wonders about this change, and probably something we should all consider more broadly. When I saw the Trac ticket I wondered if it was even necessary as there’s no actual conflict this resolves.
It probably warrants a post on Make for more feedback, but given that it only changes test code it can at least be re-done if strong objections rise up. We already have plenty of changes for change sake and this won’t materially impact that.
lancewillett
left a comment
There was a problem hiding this comment.
Following up on Dennis’s point: I’m holding the broad naming migration while we separate necessity from compatibility. The concrete issue in #62004, problem 7, is the dependency on PHPUnit\Util\Test::parseTestMethodAnnotations(), which is absent from PHPUnit 11. The current patch replaces that parser, but renaming the expectation methods and annotations is not required to remove the dependency.
I’m testing a narrower parser-only change with existing annotations and method names preserved. I’ll share the before/after evidence before proposing that split. The naming migration can remain a separate design discussion; Dennis’s review is no longer the blocker.
AI review · gpt-6
|
The narrower change now has before/after evidence. On PHP 8.3 with PHPUnit 11.5, 12 existing cases fail during setup with Important limit: PHPUnit 11 also encounters the separate removal of @Sukhendu2002, could you narrow this PR to reading the existing AI review · |
lancewillett
left a comment
There was a problem hiding this comment.
Thanks for narrowing this to the parser change. This addresses my change request while preserving existing method names, annotations, and callers.
The concrete benefit is now verified at this head: on PHPUnit 11, the same 12 existing cases error during setup without the patch and pass with it (25 assertions), in single-site and multisite with three matching random seeds. Both sides use the same temporary getGroups()/groups() bridge for a separate compatibility issue; this is parser-specific evidence, not a claim that the full suite supports PHPUnit 11. Existing metadata deprecations remain. PHPUnit 9 comparisons and PHPCS also pass.
No additional test fixtures or naming migration are needed here. Please update the title/description to describe annotation-parser compatibility; the broader naming discussion can stay on the ticket. I requested a fresh Copilot pass on the narrowed diff.
AI review · gpt-6
Read deprecation and incorrect-usage annotations through reflection instead of PHPUnit's internal parser, which is unavailable in PHPUnit 11. Preserve existing expectation methods, annotation names, and callers. Developed in: #13848 Props sukhendu2002, hellofromtonya, jrf, sergeybiryukov, dmsnell. See #54029. git-svn-id: https://develop.svn.wordpress.org/trunk@65465 602fd350-edb4-49c9-b593-d223f7449a82
|
PR #13848 landed in https://core.trac.wordpress.org/changeset/65465 |
Read deprecation and incorrect-usage annotations through reflection instead of PHPUnit's internal parser, which is unavailable in PHPUnit 11. Preserve existing expectation methods, annotation names, and callers. Developed in: WordPress/wordpress-develop#13848 Props sukhendu2002, hellofromtonya, jrf, sergeybiryukov, dmsnell. See #54029. Built from https://develop.svn.wordpress.org/trunk@65465 git-svn-id: http://core.svn.wordpress.org/trunk@64586 1a063a9b-81f0-0310-95a4-ce76da25c4cd


Replace the removed PHPUnit annotation parser with reflection-based parsing for WordPress deprecation and incorrect-usage expectations. PHPUnit 11 removes the internal parser used during test setup. Existing expectation methods, annotation names, and callers are preserved.
The broader naming proposal remains on the ticket. This change removes one PHPUnit 11 compatibility blocker; it does not establish full-suite PHPUnit 11 support.
Trac ticket: https://core.trac.wordpress.org/ticket/54029
Use of AI Tools
Example disclosure:
AI assistance: Yes
Tool(s): Pi
Model(s): GPT-5.6
Used for: Ticket analysis, test migration.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.