Opened 5 months ago
Last modified 2 days ago
#64225 new task (blessed)
Test tool and unit test improvements for 7.0
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
- #63167 (6.9)
- #62280 (6.8)
- #61530 (6.7)
- #60705 (6.6)
- #59647 (6.5)
- #58955 (6.4)
- #57841 (6.3)
- #56793 (6.2)
- #55652 (6.1)
- #54725 (6.0)
- #53363 (5.9)
- #52625 (5.8)
- #51802 (5.7)
- #51344 (5.6)
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.
Change History (71)
This ticket was mentioned in PR #10014 on WordPress/wordpress-develop by @rollybueno.
5 months ago
#1
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #10057 on WordPress/wordpress-develop by @jignesh.nakrani.
5 months ago
#2
Update unsupported image format tests to use TGA instead of AVIF
Trac ticket:
https://core.trac.wordpress.org/ticket/64225
https://core.trac.wordpress.org/ticket/63167
Updated REST API test methods using the unsupported image format to test unsupported logic checks
This ticket was mentioned in PR #10060 on WordPress/wordpress-develop by @paulbonneau.
5 months ago
#3
Adding PHPUnit tests for get_post_states function
Trac ticket:
https://core.trac.wordpress.org/ticket/64225
https://core.trac.wordpress.org/ticket/63167
This ticket was mentioned in PR #10519 on WordPress/wordpress-develop by @desrosj.
5 months ago
#4
MySQL 9.5 is the most recent innovation release. This should be tested against appropriately.
Trac ticket: Core-64225
@desrosj commented on PR #10519:
5 months ago
#6
Merged in r61245.
@westonruter commented on PR #10060:
5 months ago
#7
@paulbonneau There's a merge conflict. Could you resolve?
@paulbonneau commented on PR #10060:
5 months ago
#8
@paulbonneau There's a merge conflict. Could you resolve?
Hi @westonruter, the merge conflict has been resolved
This ticket was mentioned in PR #10642 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#9
These tests failed with semantically equivalent HTML while working on https://github.com/WordPress/wordpress-develop/pull/10639.
assertEqualHTML makes the tests more robust.
Trac ticket: https://core.trac.wordpress.org/ticket/64225
This ticket was mentioned in PR #10643 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#10
Fix class names or filename to match PHPUnit expectations.
PHPUnit can be run with a filename argument:
phpunit [options] UnitTest.php
However, certain test files and test suite class names do not align with PHPUnit expectations and it may fail to run any tests, for example:
./vendor/bin/phpunit tests/phpunit/tests/rest-api/rest-controller.php
Class rest-controller could not be found in /Users/jonsurrell/a8c/wordpress-develop/trunk/tests/phpunit/tests/rest-api/rest-controller.php
Trac ticket: https://core.trac.wordpress.org/ticket/64225
@SergeyBiryukov commented on PR #10642:
4 months ago
#12
Thanks for the PR! Merged in r61391.
@jonsurrell commented on PR #10643:
4 months ago
#13
Abandoning this based on https://core.trac.wordpress.org/ticket/62004.
This ticket was mentioned in PR #10644 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#14
These tests failed with semantically equivalent HTML while working on https://github.com/WordPress/wordpress-develop/pull/10641.
assertEqualHTML makes the tests more resilient to semantically irrelevant changes.
Trac ticket: https://core.trac.wordpress.org/ticket/64225
@SergeyBiryukov commented on PR #10644:
4 months ago
#16
Thanks for the PR! Merged in r61392.
This ticket was mentioned in PR #10649 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#17
Trac ticket: https://core.trac.wordpress.org/ticket/64225
@SergeyBiryukov commented on PR #10649:
4 months ago
#19
Thanks for the PR! Merged in r61394.
This ticket was mentioned in PR #10657 on WordPress/wordpress-develop by @jonsurrell.
4 months ago
#21
These tests failed with semantically equivalent HTML while working on https://github.com/WordPress/wordpress-develop/pull/10656.
assertEqualHTML makes the tests more robust.
Trac ticket: https://core.trac.wordpress.org/ticket/64225
@jonsurrell commented on PR #10657:
4 months ago
#23
Merged in r61409.
This ticket was mentioned in PR #10727 on WordPress/wordpress-develop by @jonsurrell.
3 months ago
#25
assertEqualHTML makes the tests resilient to irrelevant syntactic changes.
Extracted from https://github.com/WordPress/wordpress-develop/pull/10639.
Trac ticket: https://core.trac.wordpress.org/ticket/64225
@jonsurrell commented on PR #10727:
3 months ago
#27
Merged in r61478.
This ticket was mentioned in PR #10810 on WordPress/wordpress-develop by @huzaifaalmesbah.
3 months ago
#28
Ticket: https://core.trac.wordpress.org/ticket/64225
Adds unit tests to cover named entities, numeric entities, and edge cases in WP_HTML_Decoder, achieving 100% code coverage.
Changes:
- Added
test_decode_attribute_decodes_named_entitiesfor standard named entities. - Added
test_decode_attribute_decodes_hex_numeric_entitiesandtest_decode_attribute_decodes_decimal_numeric_entities. - Added
test_decodes_windows_1252_mapped_charactersto verify C1 control mappings. - Added edge case tests for invalid numeric entities, null bytes, and 4-byte UTF-8 characters (emojis).
- Added
test_decodes_ambiguous_ampersandsfor context-specific behavior.
Testing:
Run npm run test:php -- --group html-api to verify. All tests pass.
This ticket was mentioned in PR #10847 on WordPress/wordpress-develop by @jonsurrell.
3 months ago
#29
This file was added in https://github.com/WordPress/wordpress-develop/pull/9014
but missing from r60516.
While reviewing another PR, I noticed Failed to load resource: net::ERR_FILE_NOT_FOUND errors in the qunit tests and investigated. It led me to this line which references a file that doesn't exist in the repo:
See https://core.trac.wordpress.org/ticket/63126.
Trac ticket: https://core.trac.wordpress.org/ticket/64225
@jonsurrell commented on PR #10847:
3 months ago
#30
Testing can confirm that there are no Failed to load resource: net::ERR_FILE_NOT_FOUND messages on CI:
https://github.com/WordPress/wordpress-develop/actions/runs/21587508566/job/62199177243?pr=10847
[Trunk does have them:
](https://github.com/WordPress/wordpress-develop/actions/runs/21586989732/job/62197454498)
Running "qunit:files" (qunit) task Testing tests/qunit/compiled.html JQMIGRATE: Migrate is installed, version 3.4.1 Failed to load resource: net::ERR_FILE_NOT_FOUND .....................................................................................................................................................................................................................OK Testing tests/qunit/index.html JQMIGRATE: Migrate is installed with logging active, version 3.4.1 Failed to load resource: net::ERR_FILE_NOT_FOUND .....................................................................................................................................................................................................................OK
@jonsurrell commented on PR #10847:
3 months ago
#31
I'm surprised this was not caught by quint and reported as an error:
https://qunitjs.com/api/extension/QUnit.onUncaughtException/
@mukesh27 commented on PR #10847:
3 months ago
#32
I'm surprised this was not caught by quint and reported as an error:
https://qunitjs.com/api/extension/QUnit.onUncaughtException/
+1 Let's explore why it was not shown the error and commit this one
@jonsurrell commented on PR #10847:
2 months ago
#34
Merged in r61625.
This ticket was mentioned in PR #10950 on WordPress/wordpress-develop by @Rahmohn.
2 months ago
#35
#44
@
5 weeks ago
Leaving this open for a bit longer since there seems to be a few open PRs remaining.
Created #64894 for the 7.1 release cycle.
This ticket was mentioned in PR #11381 on WordPress/wordpress-develop by @desrosj.
4 weeks ago
#45
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-64225.
## 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.
@desrosj commented on PR #11381:
4 weeks ago
#46
Tested with the $this->skipOnAutomatedBranches() commented out so that the test would run within the PR's workflow runs. Tests pass.
@desrosj commented on PR #11381:
4 weeks ago
#47
Merged in r62170.
@SergeyBiryukov commented on PR #10950:
3 weeks ago
#48
Thanks for the PR! Merged in r61715.
This ticket was mentioned in PR #11403 on WordPress/wordpress-develop by @westonruter.
3 weeks ago
#49
See Slack discussion raised by @sirreal.
Erroneously introduced in https://github.com/WordPress/wordpress-develop/commit/a0b67495342265ee4de947d783569c23fa7adca2 (r41773) for Core-40104. The PHP tags were surely copied incorrectly from the PHP source file as opposed to being copied from the source code view in the browser.
Trac ticket: https://core.trac.wordpress.org/ticket/64225
## Use of AI Tools
None
@westonruter commented on PR #11403:
3 weeks ago
#51
Committed in r62184 (15e60ff)
This ticket was mentioned in PR #11524 on WordPress/wordpress-develop by @sagardeshmukh.
13 days ago
#58
## What
This PR makes two types of test improvements across three test files.
---
### 1. Add missing
@coversannotations
Adds
@coverstags to test classes that were missing them, as part of the
ongoing effort in #64225:
| File | Annotation added |
|
|
tests/phpunit/tests/rewrite/addRewriteRule.php|@covers ::add_rewrite_rule|
|tests/phpunit/tests/rewrite/addRewriteEndpoint.php|@covers ::add_rewrite_endpoint|
|tests/phpunit/tests/blocks/wpBlockTypeRegistry.php|@covers WP_Block_Type_Registry|
Both
add_rewrite_rule()andadd_rewrite_endpoint()are defined in
src/wp-includes/rewrite.php.
Without
@covers, PHPUnit cannot correctly attribute code coverage to the
functions under test, which leads to inaccurate coverage reports on Codecov.
---
### 2. Refactor repeated invalid block name tests to use a data provider
In
Tests_Blocks_wpBlockTypeRegistry, four separate test methods were
structurally identical — each registered one invalid block name and asserted
false:
test_invalid_non_string_names()test_invalid_names_without_namespace()test_invalid_characters()test_uppercase_characters()
These have been consolidated into a single
test_invalid_block_names()method
backed by adata_invalid_block_names()data provider with named cases,
following the same pattern used in recently updated tests across the suite.
Before: 4 methods × ~9 lines each = ~36 lines
After: 1 method + 1 data provider = ~21 lines
Named data sets also make PHPUnit failure output more readable — instead of
test_invalid_charactersyou see `test_invalid_block_names with data set
"invalid characters"`, which is clearer at a glance.
---
## Testing
Ran all three affected test classes locally:
npm run test:php -- --filter "Tests_Rewrite_AddRewriteRule|Tests_Rewrite_AddRewriteEndpoint|Tests_Blocks_wpBlockTypeRegistry"
OK (20 tests, 42 assertions)
All passing. The data provider runs each case as its own PHPUnit test, so the
assertion count is unchanged.
---
## Trac
---
_This is my first contribution to WordPress core. I've enabled "Allow edits
and access to secrets by maintainers". Happy to adjust anything based on
review feedback._
---
This test verifies that post meta cache persists (is not invalidated) when a post is updated, which documents the actual WordPress cache behavior.
Trac ticket:
https://core.trac.wordpress.org/ticket/64225
https://core.trac.wordpress.org/ticket/63167