WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/05/2014 12:45:53 AM (7 years ago)
Author:
azaozz
Message:

Consolidate handling of <object>, <audio> and <video> in wpautop() and add unit tests for them. Part props wonderboymusic, see #26864

File:
1 edited

Legend:

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

    r26978 r27094  
    365365        $this->assertEquals( $contents, $matches );
    366366    }
     367
     368    /**
     369     * Test [video] shortcode processing
     370     *
     371     * @ticket 26864
     372     */
     373    function test_video_shortcode_body() {
     374        $width = 720;
     375        $height = 480;
     376
     377        $video =<<<VIDEO
     378[video width="720" height="480" mp4="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4"]
     379<!-- WebM/VP8 for Firefox4, Opera, and Chrome -->
     380<source type="video/webm" src="myvideo.webm" />
     381<!-- Ogg/Vorbis for older Firefox and Opera versions -->
     382<source type="video/ogg" src="myvideo.ogv" />
     383<!-- Optional: Add subtitles for each language -->
     384<track kind="subtitles" src="subtitles.srt" srclang="en" />
     385<!-- Optional: Add chapters -->
     386<track kind="chapters" src="chapters.srt" srclang="en" />
     387[/video]
     388VIDEO;
     389
     390        $w = $GLOBALS['content_width'];
     391        $h = ceil( ( $height * $w ) / $width );
     392
     393        $content = apply_filters( 'the_content', $video );
     394
     395        $expected = '<div style="width: ' . $w . 'px; max-width: 100%;" class="wp-video">' .
     396            "<!--[if lt IE 9]><script>document.createElement(\'video\');</script><![endif]-->\n" .
     397            '<video class="wp-video-shortcode" id="video-0-1" width="' . $w . '" height="' . $h . '" preload="metadata" controls="controls">' .
     398            '<source type="video/mp4" src="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4" />' .
     399            '<!-- WebM/VP8 for Firefox4, Opera, and Chrome --><source type="video/webm" src="myvideo.webm" />' .
     400            '<!-- Ogg/Vorbis for older Firefox and Opera versions --><source type="video/ogg" src="myvideo.ogv" />' .
     401            '<!-- Optional: Add subtitles for each language --><track kind="subtitles" src="subtitles.srt" srclang="en" />' .
     402            '<!-- Optional: Add chapters --><track kind="chapters" src="chapters.srt" srclang="en" />' .
     403            '<a href="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4">' .
     404            "http://domain.tld/wp-content/uploads/2013/12/xyz.mp4</a></video></div>\n";
     405
     406        $this->assertEquals( $expected, $content );
     407    }
    367408}
Note: See TracChangeset for help on using the changeset viewer.