Repository navigation
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:
|
There was a problem hiding this comment.
🟡 Changes recommended
The fixture lacks a commented-out autoplay video, so it does not verify that such content remains unchanged and no module is enqueued.
1 open issue
What changed in this PR
Adds unit tests for render_block_core_video(), expanding coverage of server-side Video block rendering without changing production behavior.
Changes:
- Tests attachment dimensions, existing styles, and invalid IDs or metadata.
- Covers autoplay directives, script-module enqueueing, and first-video-only handling.
- Uses HTML attribute assertions to avoid depending on attribute order.
| File | Description |
|---|---|
tests/phpunit/tests/blocks/renderVideo.php |
Adds Video block rendering tests with attachment fixtures and isolated script-module state. |
Review effort: Balanced
…tests. See #66515.

Adds unit tests for
render_block_core_video()insrc/wp-includes/blocks/video.php, which was not referenced by any test. No behavior is changed.The new test class
tests/phpunit/tests/blocks/renderVideo.phpcovers:<videotag is returned unchanged and enqueues nothing (the check is case-insensitive, so<VIDEO>is handled).width,heightandaspect-ratiostyle are added from the attachment metadata, replace existing dimensions, are placed before an existingstyle, replace astyleattribute without a value, and are only added to the first video.idis missing, null, zero, negative, a numeric string, a float or an array, when the current post is set and theidis zero, when theidis a post that is not an attachment or does not exist, or when the metadata has no valid dimensions (missing, zero, negative, string, float or null).autoplayattribute (boolean, empty, uppercase or with a value) getsdata-wp-interactive="core/video"anddata-wp-init="callbacks.stopAutoplay"and enqueues the@wordpress/block-library/video/viewscript module. A video without it, or anautoplaythat is only on a second video, does not.The tests check the attributes of the video with
WP_HTML_Tag_Processorinstead of comparing the whole markup, because the order in which the processor adds new attributes is not part of the contract.register_block_core_video()is not tested here, because it needs the builtblock.jsonof the block.Testing:
vendor/bin/phpunit --filter Tests_Blocks_RenderVideovendor/bin/phpunit -c tests/phpunit/multisite.xml --filter Tests_Blocks_RenderVideovendor/bin/phpcs tests/phpunit/tests/blocks/renderVideo.phpI also temporarily broke the function (the case-insensitive check, the autoplay check, the enqueue, each directive, the update of the content, the type check of the
id, the zero check, the attachment check, the integer and positive checks of the dimensions, each attribute, the order of the style, the order of the ratio and the string check of the style) and confirmed that a new test fails for each one, except for removing the early return for content without a video, which does not change the result because the tag processor finds no video.Trac ticket: https://core.trac.wordpress.org/ticket/66515
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.
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.