Make WordPress Core

Ticket #33106: 33106.tests.media.mod-hook.4.patch

File 33106.tests.media.mod-hook.4.patch, 2.7 KB (added by kitchin, 10 years ago)
  • tests/phpunit/tests/media.php

     
    585585                $this->assertEquals( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt );
    586586        }
    587587
     588        /**
     589         * @ticket 33016
     590         */
     591        function test_multiline_cdata() {
     592                global $wp_embed;
     593
     594                $content = <<<EOF
     595<script>// <![CDATA[
     596_my_function('data');
     597// ]]>
     598</script>
     599EOF;
     600
     601                $result = $wp_embed->autoembed( $content );
     602                $this->assertEquals( $content, $result );
     603        }
     604
     605        /**
     606         * @ticket 33016
     607         */
     608        function test_multiline_comment() {
     609                global $wp_embed;
     610
     611                $content = <<<EOF
     612<script><!--
     613my_function();
     614// --> </script>
     615EOF;
     616
     617                $result = $wp_embed->autoembed( $content );
     618                $this->assertEquals( $content, $result );
     619        }
     620
     621
     622        /**
     623         * @ticket 33016
     624         */
     625        function test_multiline_comment_with_embeds() {
     626                $content = <<<EOF
     627Start.
     628[embed]http://www.youtube.com/embed/TEST01YRHA0[/embed]
     629<script><!--
     630my_function();
     631// --> </script>
     632http://www.youtube.com/embed/TEST02YRHA0
     633[embed]http://www.example.com/embed/TEST03YRHA0[/embed]
     634http://www.example.com/embed/TEST04YRHA0
     635Stop.
     636EOF;
     637
     638                $expected = <<<EOF
     639<p>Start.<br />
     640https://youtube.com/watch?v=TEST01YRHA0<br />
     641<script><!--
     642my_function();
     643// --> </script><br />
     644https://youtube.com/watch?v=TEST02YRHA0<br />
     645<a href="http://www.example.com/embed/TEST03YRHA0">http://www.example.com/embed/TEST03YRHA0</a><br />
     646http://www.example.com/embed/TEST04YRHA0<br />
     647Stop.</p>
     648
     649EOF;
     650
     651                $result = apply_filters('the_content', $content );
     652                $this->assertEquals( $expected, $result );
     653        }
     654
     655        /**
     656         * @ticket 33016
     657         */
     658        function filter_wp_embed_shortcode_custom( $custom, $attr, $url ) {
     659                if ( $url === 'https://www.example.com/?video=1' ) {
     660                        $custom = "<iframe src='$url'></iframe>";
     661                }
     662                return $custom;
     663        }
     664
     665        /**
     666         * @ticket 33016
     667         */
     668        function test_oembed_explicit_media_link() {
     669                global $wp_embed;
     670                add_filter( 'wp_embed_shortcode_custom', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 3 );
     671
     672                $content = <<<EOF
     673https://www.example.com/?video=1
     674EOF;
     675
     676                $expected = <<<EOF
     677<iframe src='https://www.example.com/?video=1'></iframe>
     678EOF;
     679
     680                $result = $wp_embed->autoembed( $content );
     681                $this->assertEquals( $expected, $result );
     682
     683                $content = <<<EOF
     684<a href="https://www.example.com/?video=1">https://www.example.com/?video=1</a>
     685EOF;
     686
     687                $result = $wp_embed->autoembed( $content );
     688                $this->assertEquals( $content, $result );
     689
     690                remove_filter( 'wp_embed_shortcode_custom', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 );
     691        }
    588692}