Make WordPress Core

Changeset 64059


Ignore:
Timestamp:
10/02/2026 05:16:44 PM (8 weeks ago)
Author:
lancewillett
Message:

Tests: Handle video shortcode instance numbers in tests.

Capture the video shortcode instance number through its filter and use it in the expected markup. Preserve the full markup assertion without assuming this is the first video rendered in the process.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13904

Props adrianmoldovanwp.
See #65893.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r64042 r64059  
    15351535                $h = ceil( ( $height * $width ) / $width );
    15361536
     1537                // wp_video_shortcode() numbers every call in the process, so record this call's number.
     1538                $instance = 0;
     1539                add_filter(
     1540                        'wp_video_shortcode_override',
     1541                        static function ( $html, $attr, $content, $id ) use ( &$instance ) {
     1542                                $instance = $id;
     1543                                return $html;
     1544                        },
     1545                        10,
     1546                        4
     1547                );
     1548
    15371549                $content = apply_filters( 'the_content', $video );
    15381550
    15391551                $expected = '<div style="width: ' . $width . 'px;" class="wp-video">' .
    1540                         '<video class="wp-video-shortcode" id="video-' . $post_id . '-1" width="' . $width . '" height="' . $h . '" preload="metadata" controls="controls">' .
    1541                         '<source type="video/mp4" src="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4?_=1" />' .
     1552                        '<video class="wp-video-shortcode" id="video-' . $post_id . '-' . $instance . '" width="' . $width . '" height="' . $h . '" preload="metadata" controls="controls">' .
     1553                        '<source type="video/mp4" src="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4?_=' . $instance . '" />' .
    15421554                        '<!-- WebM/VP8 for Firefox4, Opera, and Chrome --><source type="video/webm" src="myvideo.webm" />' .
    15431555                        '<!-- Ogg/Vorbis for older Firefox and Opera versions --><source type="video/ogg" src="myvideo.ogv" />' .
Note: See TracChangeset for help on using the changeset viewer.