#64894 closed task (blessed) (fixed)
Test tool and unit test improvements for 7.1
| Reported by: | desrosj | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
This ticket is for various fixes and improvements in PHPUnit tests that don't have a more specific ticket, as well as general improvements to the GitHub Actions workflows that run automated testing.
Previous releases:
Change History (90)
This ticket was mentioned in PR #11381 on WordPress/wordpress-develop by @desrosj.
8 months ago
#1
- Keywords has-patch has-unit-tests added
@desrosj commented on PR #11381:
8 months ago
#3
Merged in r62170.
This ticket was mentioned in PR #11433 on WordPress/wordpress-develop by @johnbillion.
7 months ago
#4
The e2e and performance tests switched from Puppeteer to Playwright. One of the things that prevents Puppeteer being removed as a dependency is the grunt-contrib-qunit test runner which uses Puppeteer.
This replaces the runner with a Playwright config.
Notes:
grunt-contrib-qunitreports test counts, this Playwright config reports assertion counts, hence the number of passes has changed from 456 to 535. The actual tests and assertions have not changed.puppeteer-coreis still a transitive dependency after this change due towp-scriptsandlighthouse. One step at a time.qunit/editorhasn't existed since https://core.trac.wordpress.org/changeset/40584 nine years ago.
@johnbillion commented on PR #11433:
7 months ago
#5
After further thought, I think the AppArmor config in .github/workflows/reusable-javascript-tests.yml will need to be retained. Removing it will cause older branches that use Puppeteer to start failing.
This ticket was mentioned in PR #11925 on WordPress/wordpress-develop by @johnbillion.
6 months ago
#7
Trac ticket: https://core.trac.wordpress.org/ticket/64894
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.7
Used for: Initial investigation and changes, with follow-ups and fixes by me.
This ticket was mentioned in PR #11810 on WordPress/wordpress-develop by @desrosj.
6 months ago
#8
MySQL 9.7.0 LTS was released on April 21, 2026.
The testing matrices should be updated to reflect this. Also, there are now no MySQL innovation releases actively supported until a new one is published in a few months.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
## Use of AI Tools
None.
@desrosj commented on PR #11810:
6 months ago
#10
Merged in r62407.
@johnbillion commented on PR #11433:
6 months ago
#12
This ticket was mentioned in PR #12073 on WordPress/wordpress-develop by @jorbin.
5 months ago
#13
Use a dataProvider in order to simplify code
Trac ticket: https://core.trac.wordpress.org/ticket/64894
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot and Opencode
Model(s): Claude Sonnet 4.6
Used for: Initial code investigation and suggestions; final implementation was reviewed and edited by me.
@jorbin commented on PR #12073:
5 months ago
#15
Committed in https://core.trac.wordpress.org/changeset/62462
This ticket was mentioned in PR #12208 on WordPress/wordpress-develop by @Soean.
5 months ago
#19
This pull request updates and clarifies parameter names and docblocks in various PHPUnit test files to improve code readability and maintainability. The changes primarily focus on making parameter names more descriptive and aligning them with their actual usage in the test methods.
These updates do not affect test logic but enhance code quality and developer experience by making the test suite easier to understand and maintain.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12238 on WordPress/wordpress-develop by @desrosj.
5 months ago
#20
This pins the Gutenberg plugin to version 23.3.2 (the last version compatible with WP 6.8) in E2E test workflow.
Trac ticket: Core-64894, Core-64894.
## Use of AI Tools
None.
@desrosj commented on PR #12238:
5 months ago
#23
Merged in r62544.
This ticket was mentioned in PR #12301 on WordPress/wordpress-develop by @Soean.
5 months ago
#24
The sprintf( '/wp/v2/posts' ) call wraps a plain string literal without any placeholders or additional arguments, so it returns the string unchanged. Passing the literal directly to WP_REST_Request is equivalent and clearer.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12302 on WordPress/wordpress-develop by @Soean.
5 months ago
#25
## Description
Tests_Compat_mbSubstr::data_utf8_substrings() declared every data set with the same array key 'баба'. Since PHP keeps only the last value for a duplicate array key, all but the final 'баба' entry were silently discarded — only 2 of the 12 intended cases were actually executed by test_mb_substr() and test_8bit_mb_substr().
This change replaces the duplicated keys with unique, descriptive ones that name the $start / $length scenario each case covers (e.g. negative start, positive length, start beyond length, large negative length). All previously dropped cases now run, and failures point directly to the relevant scenario.
The duplicate keys were introduced in [60969].
## Testing instructions
Run the affected tests:
npm run test:php -- --filter Tests_Compat_mbSubstr tests/phpunit/tests/compat/mbSubstr.php
Before: (23 tests)
Now: (43 tests) - the data provider now contributes 12 distinct cases per test method instead of 2.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12303 on WordPress/wordpress-develop by @Soean.
5 months ago
#26
## Description
Tests_Formatting_SanitizeKey::data_sanitize_key() declared two data sets with the same key 'a lowercase key with commas'. Since PHP keeps only the last value for a duplicate array key, the first case (howdy,admin) was silently discarded and never ran.
On top of that, the second case is mislabeled: its input is HOWDY,ADMIN, i.e. uppercase, not lowercase. Together with the following 'a mixed case key with commas' case, the clear intent is to cover lowercase / uppercase / mixed input.
This renames the second case to 'an uppercase key with commas', fixing both the duplicate key and the inaccurate label, and restoring the dropped lowercase case.
The duplicate key was introduced in [52292].
## Testing instructions
Run the affected tests:
npm run test:php -- --filter Tests_Formatting_SanitizeKey tests/phpunit/tests/formatting/sanitizeKey.php
All cases pass, and the data provider now contributes the lowercase, uppercase, and mixed-case scenarios instead of dropping the lowercase one.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12329 on WordPress/wordpress-develop by @Soean.
5 months ago
#27
Corrects the data provider label in Tests_Post_TruncatePostSlug: the test case with length=12 was incorrectly named "fifth" instead of "sixth", duplicating the key of the previous test case. As a result, the length=12 test was silently overwritten and never executed. This fix restores the correct label so both boundary cases are now covered.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12331 on WordPress/wordpress-develop by @Soean.
5 months ago
#28
Renames the duplicate data provider key "with other og meta" to "with other og meta and HTML content" in Tests_REST_WpRestUrlDetailsController. The key appeared twice (lines 957 and 1023), causing the first test case to be silently overwritten by the second and never executed. The new name also better describes what the test covers: og meta tags whose content attribute contains HTML markup.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
@mukesh27 commented on PR #12331:
5 months ago
#29
Nice catch! Introduce in https://core.trac.wordpress.org/changeset/51973
@mukesh27 commented on PR #12329:
5 months ago
#30
Introduce in https://core.trac.wordpress.org/changeset/55208
@dmsnell commented on PR #12302:
5 months ago
#32
@Soean commented on PR #12303:
4 months ago
#35
@Soean commented on PR #12303:
4 months ago
#36
This ticket was mentioned in PR #12412 on WordPress/wordpress-develop by @Soean.
4 months ago
#37
Removes redundant array entries that were silently overwritten by a later key with the same name.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
@Soean commented on PR #12301:
4 months ago
#39
@Soean commented on PR #12329:
4 months ago
#42
@Soean commented on PR #12331:
4 months ago
#43
@Soean commented on PR #12412:
4 months ago
#45
This ticket was mentioned in PR #12464 on WordPress/wordpress-develop by @jorbin.
4 months ago
#46
Trac Ticket: https://core.trac.wordpress.org/ticket/64894
AI assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet 5
Used for: Initial code skeleton, final implementation was reviewed and modified by me
@jorbin commented on PR #12464:
4 months ago
#48
Committed in https://core.trac.wordpress.org/changeset/62713
This ticket was mentioned in PR #12509 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#49
The web-platform-tests test suite for the HTML API (previously html5lib-tests) used return for the final case, which is not reached by iteration. The final test case in each test file was never run.
Diff with trunk: ./vendor/bin/phpunit --group=html-api-web-platform-tests
-Tests: 1655, Assertions: 1221, Skipped: 434. +Tests: 1707, Assertions: 1261, Failures: 1, Skipped: 446.
The failure is due to https://github.com/web-platform-tests/wpt/pull/61257 (an incorrect tree in WPT) and is temporarily disabled on this branch.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12511 on WordPress/wordpress-develop by @Soean.
4 months ago
#50
Using the dedicated boolean assertions clarifies intent and produces more descriptive failure messages.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
@jonsurrell commented on PR #12509:
4 months ago
#52
Merged in r62724.
This ticket was mentioned in PR #12513 on WordPress/wordpress-develop by @Soean.
4 months ago
#53
Replace boolean assertions wrapping other checks with the dedicated PHPUnit assertions:
assertContains()/assertNotContains()instead ofin_array()orarray_search()wrapped inassertTrue()/assertFalse().assertEmpty()instead ofassertTrue( empty( ... ) ).assertDirectoryExists()instead ofassertTrue( is_dir( ... ) ). This clarifies intent and produces more descriptive failure messages.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12515 on WordPress/wordpress-develop by @Soean.
4 months ago
#54
Replace foreach loops calling assertInstanceOf() on each element with a single assertContainsOnlyInstancesOf() assertion. This clarifies intent, reduces boilerplate, and produces more descriptive failure messages.
Docs: https://docs.phpunit.de/en/13.2/assertions.html#assertcontainsonlyinstancesof
Trac ticket: https://core.trac.wordpress.org/ticket/64894
@SergeyBiryukov commented on PR #12513:
4 months ago
#55
Thanks for the PR! The wpdb changes should probably be reverted, they cause warnings when running the tests:
Undefined property: wpdb::$dbh
This ticket was mentioned in PR #12521 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#56
Update web platform tests to latest version.
Remove invalid test skip (fixed): https://github.com/web-platform-tests/wpt/pull/61257
Trac ticket: https://core.trac.wordpress.org/ticket/64894
Follow-up to r62724.
## Use of AI Tools
@jonsurrell commented on PR #12521:
4 months ago
#58
Merged in r62734.
@Soean commented on PR #12513:
4 months ago
#59
Thanks for the feedback, I updated the code.
This ticket was mentioned in PR #12537 on WordPress/wordpress-develop by @Soean.
4 months ago
#61
Replace verbose isset()-and-return blocks with the ?? operator in the object cache helper and font-face test dataset.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
@Soean commented on PR #12513:
4 months ago
#63
This ticket was mentioned in PR #12558 on WordPress/wordpress-develop by @Soean.
4 months ago
#64
This refactors the tests in tests/phpunit/tests/formatting/urlShorten.php and adds coverage that was missing.
### Misplaced test argument
The case meant to test the optional $length parameter passed the length as the third argument to assertSame():
$this->assertSame( 'wordpress.org/about/philosophy/#…', url_shorten( 'http://wordpress.org/about/philosophy/#decisions' ), 31 );
That third argument is assertSame()'s $message, not the URL length. So url_shorten() ran with its default length of 35, the expected value happened to match the default output, and the assertion passed — while the $length parameter was never actually tested.
### Changes
- Convert the tests to
@dataProviderdata sets with descriptive keys, so a failure points to the exact case. - Separate the default-behaviour cases from the custom-length cases.
- Add real coverage for
$length: the URL is kept when the length exceeds or equals the cleaned URL (pinning the strict>comparison) and shortened when it is smaller. - Add a comment clarifying that a shortened URL is cut to
( $length - 3 )characters before…is appended.
No production code is changed — this is a test-only improvement.
All tests pass locally via npm run test:php -- --filter Tests_Formatting_UrlShorten (9 tests, 9 assertions).
Trac ticket: https://core.trac.wordpress.org/ticket/64894
@mukesh27 commented on PR #12558:
4 months ago
#65
Introduce in https://core.trac.wordpress.org/changeset/35314
@Soean commented on PR #12558:
4 months ago
#67
This ticket was mentioned in PR #12599 on WordPress/wordpress-develop by @peterwilsoncc.
4 months ago
#69
Try speeding up the AJAX test suite by re-using roles between tests.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
## Use of AI Tools
VS Code/Co-pilot type ahead.
@peterwilsoncc commented on PR #12599:
4 months ago
#70
This is a nope. Creating the shared fixtures in the test suite slows things down rather than speeds thigns up.
A lot of accounts are created but evidently fewer than this PR creates.
@SergeyBiryukov commented on PR #12537:
4 months ago
#76
Thanks for the PR! Merged in r62870.
@wildworks commented on PR #12208:
3 months ago
#78
@SergeyBiryukov commented on PR #12511:
3 months ago
#80
Thanks for the PR! Merged in r62969.
This ticket was mentioned in PR #12818 on WordPress/wordpress-develop by @Soean.
3 months ago
#81
Using the dedicated assertNull() assertion instead of assertSame( null, $actual ) clarifies intent and produces more descriptive failure messages.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This ticket was mentioned in PR #12834 on WordPress/wordpress-develop by @Soean.
3 months ago
#82
## What
Fixes an incorrect inline @var annotation in WP_Test_REST_Users_Controller::test_get_items_only_fetches_ids_for_head_requests().
The $query variable comes from the pre_user_query filter args and is a WP_User_Query instance, the assertInstanceOf( WP_User_Query::class, ... ) on the line above asserts exactly that. The docblock incorrectly declared it as WP_User.
## Why
WP_User has no query_vars property, so the wrong annotation causes static analysis tools (PHPStan) and IDEs to report false errors on the following $query->query_vars accesses, and it misleads anyone reading the test
Trac ticket: https://core.trac.wordpress.org/ticket/64894
#83
@
3 months ago
I've gone and created #65819 for the 7.2 release cycle, but it looks like there are 2 outstanding PRs remaining here.
@SergeyBiryukov would you be able to wrap those two up so this can be closed out before RC2 next week?
@SergeyBiryukov commented on PR #12834:
3 months ago
#85
Thanks for the PR! Merged in r63160.
@SergeyBiryukov commented on PR #12818:
3 months ago
#87
Thanks for the PR! Merged in r63161.
This ticket was mentioned in PR #13557 on WordPress/wordpress-develop by @jonsurrell.
2 months ago
#89
Update the HTML API's Web Platform Tests snapshot from WPT revision `45337b8` to `d556bd7`, following the procedure in tests/phpunit/data/web-platform-tests/README.md.
Eight .dat files change: seven are updated and scripted_foster01.dat is new. Tree-construction cases go from 1,920 to 1,959.
Five of the new cases do not pass and are added to SKIP_TESTS:
html5test-com/line0149,html5test-com/line0160andhtml5test-com/line0193: the HTML Processor parses CDATA sections at SVG and MathML integration points as bogus comments. #12539 fixes this.template/line0606andtemplate/line0619: the HTML Processor does not reset the frameset-ok flag when the BODY element is inserted implicitly from the "after head" insertion mode (whatwg/html#12908).
The new adoption agency and foster parenting cases need no entry. The processor raises WP_HTML_Unsupported_Exception on them and the existing handler in the test already skips those.
Validation: --group html-api is 1,728 tests, 6,156 assertions, 1 skipped. --group html-api-web-platform-tests is 1,725 tests, 1,276 assertions, 449 skipped. phpcs is clean on the changed test file.
#12539 carries this same resync so its new CDATA cases are covered. It will drop its copy once this lands.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Copying the upstream data files, identifying which new cases fail and why, and drafting this description.
---
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.
🤖 Generated with Claude Code
@jonsurrell commented on PR #13557:
2 months ago
#90
Merged in r63651.
This fixes a failing tst that seems to be caused by the fact that MySQL changed the content on release pages.
Unfortunately, it does not seem like there is an official API available from MySQL itself. However, endoflife.date is an open source, MIT licensed, reasonably maintained project that does have an endpoint available.
Trac ticket: Core-64894.
## Use of AI Tools
AI Assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet 4.6
Used for: Searching for possible APIs to use to replace parsing an HTML document.