Skip to content

Conversation

@sirreal
Copy link
Member

@sirreal sirreal commented Jun 27, 2025

Trac ticket: https://core.trac.wordpress.org/ticket/63167

Extract the test cases for wp_kses_normalize_entities to a data provider and expand the test cases.

Using a data provider for the individual test cases gives better information and isolates each test case so that a single failure on a test case can be identified instead of manifesting as a more general failure.

The existing test cases are maintained, all for named entities. Test cases have been added for:

  • The examples in the function documentation.
  • Numeric (decimal and hex) character references.
  • Some invalid numeric character references (outside valid unicode range).

This test improvement supports the work in #9099.


Example test output using the following command:

./vendor/bin/phpunit --testdox --filter='kses_normalize_entities'

Before:

 ✔ Wp kses normalize entities
OK (1 test, 8 assertions)

After:

 ✔ Wp kses normalize entities with AT&T
 ✔ Wp kses normalize entities with :
 ✔ Wp kses normalize entities with &#XYZZY;
 ✔ Wp kses normalize entities with Named·entity:·&
 ✔ Wp kses normalize entities with Named·entity:·&
 ✔ Wp kses normalize entities with Named·entity:·♠
 ✔ Wp kses normalize entities with Named·entity:·¹
 ✔ Wp kses normalize entities with Named·entity:·²
 ✔ Wp kses normalize entities with Named·entity:·³
 ✔ Wp kses normalize entities with Named·entity:·¼
 ✔ Wp kses normalize entities with Named·entity:·½
 ✔ Wp kses normalize entities with Named·entity:·¾
 ✔ Wp kses normalize entities with Named·entity:·∴
 ✔ Wp kses normalize entities with Numeric·entity·	·(·)
 ✔ Wp kses normalize entities with Numeric·entity·"·(")
 ✔ Wp kses normalize entities with Numeric·entity·"·(")
 ✔ Wp kses normalize entities with Numeric·entity·&·(&)
 ✔ Wp kses normalize entities with Numeric·entity·'·(')
 ✔ Wp kses normalize entities with Numeric·entity·😍·(😍)
 ✔ Wp kses normalize entities with Numeric·entity·😍·(😍)
 ✔ Wp kses normalize entities with Hex·entity·	·(·)
 ✔ Wp kses normalize entities with Hex·entity·"·(")
 ✔ Wp kses normalize entities with Hex·entity·"·(")
 ✔ Wp kses normalize entities with Hex·entity·&·(&)
 ✔ Wp kses normalize entities with Hex·entity·'·(')
 ✔ Wp kses normalize entities with Hex·entity·😍·(😍)
 ✔ Wp kses normalize entities with Hex·entity·😍·(😍)
 ✔ Wp kses normalize entities with HEX·ENTITY·"·(")
 ✔ Wp kses normalize entities with HEX·ENTITY·&·(&)
 ✔ Wp kses normalize entities with HEX·ENTITY·'·(')
 ✔ Wp kses normalize entities with HEX·ENTITY·😍·(😍)
 ✔ Wp kses normalize entities with Encoded·named·entity·&
 ✔ Wp kses normalize entities with Encoded·named·entity·&
 ✔ Wp kses normalize entities with Encoded·named·entity·&
 ✔ Wp kses normalize entities with Invalid·numeric·unicode·�
 ✔ Wp kses normalize entities with Invalid·hex·unicode·�
OK (36 tests, 36 assertions)

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.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@sirreal sirreal marked this pull request as ready for review June 27, 2025 14:43
@github-actions
Copy link

github-actions bot commented Jun 27, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell, cbravobernal.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sirreal sirreal changed the title improve kses normalize entities tests Improve KSES normalize entities tests Jun 27, 2025
Copy link
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sirreal sirreal force-pushed the improve-kses-normalize-entities-tests branch from 0d6d463 to e99472c Compare July 10, 2025 15:47
pento pushed a commit that referenced this pull request Jul 10, 2025
Update test to use a data provider for test cases.
Add a variety of HTML character references covering named, decimal, and hexadecimal forms.

Developed in #9095.

Props jonsurrell, cbravobernal.
See #63167.


git-svn-id: https://develop.svn.wordpress.org/trunk@60446 602fd350-edb4-49c9-b593-d223f7449a82
@sirreal
Copy link
Member Author

sirreal commented Jul 10, 2025

Merged in [60446].

@sirreal sirreal closed this Jul 10, 2025
@sirreal sirreal deleted the improve-kses-normalize-entities-tests branch July 10, 2025 16:02
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jul 10, 2025
Update test to use a data provider for test cases.
Add a variety of HTML character references covering named, decimal, and hexadecimal forms.

Developed in WordPress/wordpress-develop#9095.

Props jonsurrell, cbravobernal.
See #63167.

Built from https://develop.svn.wordpress.org/trunk@60446


git-svn-id: http://core.svn.wordpress.org/trunk@59782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request Jul 10, 2025
Update test to use a data provider for test cases.
Add a variety of HTML character references covering named, decimal, and hexadecimal forms.

Developed in WordPress/wordpress-develop#9095.

Props jonsurrell, cbravobernal.
See #63167.

Built from https://develop.svn.wordpress.org/trunk@60446


git-svn-id: https://core.svn.wordpress.org/trunk@59782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@dmsnell
Copy link
Member

dmsnell commented Jul 11, 2025

Very nice change here. Thanks for moving commented tests into real tests, and for using the array key => value form so that the test cases are named when failing.

Ninos pushed a commit to Ninos/wordpress-develop that referenced this pull request Jul 28, 2025
Update test to use a data provider for test cases.
Add a variety of HTML character references covering named, decimal, and hexadecimal forms.

Developed in WordPress#9095.

Props jonsurrell, cbravobernal.
See #63167.


git-svn-id: https://develop.svn.wordpress.org/trunk@60446 602fd350-edb4-49c9-b593-d223f7449a82
jonnynews pushed a commit to spacedmonkey/wordpress-develop that referenced this pull request Sep 24, 2025
Update test to use a data provider for test cases.
Add a variety of HTML character references covering named, decimal, and hexadecimal forms.

Developed in WordPress#9095.

Props jonsurrell, cbravobernal.
See #63167.


git-svn-id: https://develop.svn.wordpress.org/trunk@60446 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants