Media: Add tests for get_media_embedded_in_content() - #13222
Conversation
|
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 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. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Cover the paths the existing tests in tests/phpunit/tests/media.php leave out: the default `$types` argument, an empty array of types, the `media_embedded_in_content_allowed_types` filter in both directions, repeated elements of a single type, and markup the regular expression is not meant to match. Fixes #65931.
3bb5145 to
4e8d976
Compare
get_media_embedded_in_content()has two tests intests/phpunit/tests/media.php, both covering the same happy path: well-formed markup, one element per type.This adds
tests/phpunit/tests/media/getMediaEmbeddedInContent.phpfor the paths they leave out — the default$typesargument, an empty array of types, themedia_embedded_in_content_allowed_typesfilter narrowing and extending the list, repeated elements of one type, both self-closing forms, and markup the pattern is not meant to match. Fixtures sit inside surrounding content, matching the shape used ingetTagRegex.php.The repeated-element case pins the lazy body match that
get_tag_regex()only just gained in [63331].Trac ticket: https://core.trac.wordpress.org/ticket/65931
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: characterizing the function's current behaviour and writing the test cases. All changes were reviewed and validated by me.