Make WordPress Core


Ignore:
Timestamp:
07/31/2015 01:44:04 AM (11 years ago)
Author:
azaozz
Message:

Backport r33469 and r33470 to 3.9.
See #33106.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9/tests/phpunit/tests/media.php

    r27726 r33523  
    438438        }
    439439
     440        /**
     441         * @ticket 33016
     442         */
     443        function test_multiline_cdata() {
     444                global $wp_embed;
     445
     446                $content = <<<EOF
     447<script>// <![CDATA[
     448_my_function('data');
     449// ]]>
     450</script>
     451EOF;
     452
     453                $result = $wp_embed->autoembed( $content );
     454                $this->assertEquals( $content, $result );
     455        }
     456
     457        /**
     458         * @ticket 33016
     459         */
     460        function test_multiline_comment() {
     461                global $wp_embed;
     462
     463                $content = <<<EOF
     464<script><!--
     465my_function();
     466// --> </script>
     467EOF;
     468
     469                $result = $wp_embed->autoembed( $content );
     470                $this->assertEquals( $content, $result );
     471        }
     472
     473
     474        /**
     475         * @ticket 33016
     476         */
     477        function test_multiline_comment_with_embeds() {
     478                $content = <<<EOF
     479Start.
     480[embed]http://www.youtube.com/embed/TEST01YRHA0[/embed]
     481<script><!--
     482my_function();
     483// --> </script>
     484http://www.youtube.com/embed/TEST02YRHA0
     485[embed]http://www.example.com/embed/TEST03YRHA0[/embed]
     486http://www.example.com/embed/TEST04YRHA0
     487Stop.
     488EOF;
     489
     490                $expected = <<<EOF
     491<p>Start.<br />
     492<a href="http://www.youtube.com/embed/TEST01YRHA0">http://www.youtube.com/embed/TEST01YRHA0</a><br />
     493<script><!--
     494my_function();
     495// --> </script></p>
     496<p>http://www.youtube.com/embed/TEST02YRHA0</p>
     497<p><a href="http://www.example.com/embed/TEST03YRHA0">http://www.example.com/embed/TEST03YRHA0</a></p>
     498<p>http://www.example.com/embed/TEST04YRHA0</p>
     499<p>Stop.</p>
     500
     501EOF;
     502
     503                $result = apply_filters( 'the_content', $content );
     504                $this->assertEquals( $expected, $result );
     505        }
     506
     507        /**
     508         * @ticket 33016
     509         */
     510        function filter_wp_embed_shortcode_custom( $content, $url ) {
     511                if ( 'https://www.example.com/?video=1' == $url ) {
     512                        $content = '@embed URL was replaced@';
     513                }
     514                return $content;
     515        }
     516
     517        /**
     518         * @ticket 33016
     519         */
     520        function test_oembed_explicit_media_link() {
     521                global $wp_embed;
     522                add_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 2 );
     523
     524                $content = <<<EOF
     525https://www.example.com/?video=1
     526EOF;
     527
     528                $expected = <<<EOF
     529
     530@embed URL was replaced@
     531
     532EOF;
     533
     534                $result = $wp_embed->autoembed( $content );
     535                $this->assertEquals( $expected, $result );
     536
     537                $content = <<<EOF
     538<a href="https://www.example.com/?video=1">https://www.example.com/?video=1</a>
     539<script>// <![CDATA[
     540_my_function('data');
     541myvar = 'Hello world
     542https://www.example.com/?video=1
     543do not break this';
     544// ]]>
     545</script>
     546EOF;
     547
     548                $result = $wp_embed->autoembed( $content );
     549                $this->assertEquals( $content, $result );
     550
     551                remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 );
     552        }
    440553}
Note: See TracChangeset for help on using the changeset viewer.