Skip to content

Tests: Read the video shortcode instance number in test_video_shortcode_body() - #13904

Open
lancewillett wants to merge 1 commit into
WordPress:trunkfrom
lancewillett:fix/65893-video-shortcode-instance
Open

lancewillett wants to merge 1 commit into
WordPress:trunkfrom
lancewillett:fix/65893-video-shortcode-instance

Conversation

@lancewillett

Copy link
Copy Markdown
Member

Trac ticket: core.trac.wordpress.org/ticket/65893

wp_video_shortcode() numbers every call with a static counter. It puts the number in the player's id (video-%d-%d) and in the source's _ query argument. Tests_Media::test_video_shortcode_body() expected 1, which holds only when it makes the first wp_video_shortcode() call in the process. When an earlier test has called it, such as Tests_Widgets_wpWidgetMediaVideo, the numbers differ and the test fails. In a random-order full run it got video-0-14.

The test now records the number from the wp_video_shortcode_override filter, which receives the same counter just before the markup is built. It then builds the expected markup with that number. The filter returns its input unchanged, and the base test case removes it afterward. The rest of the expected markup is unchanged.

Running this test in a separate process was tried first and dropped: the child process removes the class's shared attachment fixtures, which breaks 84 other Tests_Media tests.

Testing Instructions

  1. Start the environment: npm run env:start && npm run env:install.
  2. List tests/phpunit/tests/widgets/wpWidgetMediaVideo.php and then tests/phpunit/tests/media.php as <file> entries in a copy of phpunit.xml.dist. Run it with -c and --filter 'Tests_Widgets_wpWidgetMediaVideo|test_video_shortcode_body'. On trunk, test_video_shortcode_body fails. On this branch, all 9 tests pass.
  3. Run npm run test:php -- --filter Tests_Media in default order, --order-by=reverse, and seeds 1, 2 and 3, plus -c tests/phpunit/multisite.xml. test_video_shortcode_body passes in all of them. (test_img_caption_shortcode_with_old_format_id_and_align fails in reverse and at seeds 1 and 3 on trunk too; Tests: Improve isolation for randomized media tests #13190 addresses it.)
  4. Full suite at --order-by=random --random-order-seed=1: the video failure is gone, with no new failures.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code, Codex
Model(s): Claude Opus 5.5, gpt-6-astra (Codex review)
Used for: finding the cause, making the change, running the tests, and a second-model review


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

…ode_body()`.

`wp_video_shortcode()` numbers every call with a static counter and puts the number in the player's `id` and the source's `_` query argument. The test expected `1`, which holds only when it makes the first `wp_video_shortcode()` call in the process. When an earlier test has called it, such as `Tests_Widgets_wpWidgetMediaVideo`, the numbers differ and the test fails.

The test now records the number from the `wp_video_shortcode_override` filter and builds the expected markup with it. The rest of the expected markup is unchanged.

See #65893.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

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 lancewillett.

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

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.

2 participants