Make WordPress Core


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

Backport r33469 and r33470 to 4.0.
See #33106.

File:
1 edited

Legend:

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

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