Make WordPress Core

Ticket #33106: 33106.tests.media.3.patch

File 33106.tests.media.3.patch, 1.7 KB (added by kitchin, 10 years ago)

Maybe too much. Third additional test to show the_content application.

  • 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                global $wp_embed;
     627
     628                $content = <<<EOF
     629Start.
     630[embed]http://www.youtube.com/embed/TEST01YRHA0[/embed]
     631<script><!--
     632my_function();
     633// --> </script>
     634http://www.youtube.com/embed/TEST02YRHA0
     635[embed]http://www.example.com/embed/TEST03YRHA0[/embed]
     636http://www.example.com/embed/TEST04YRHA0
     637Stop.
     638EOF;
     639
     640                $expected = <<<EOF
     641<p>Start.<br />
     642https://youtube.com/watch?v=TEST01YRHA0<br />
     643<script><!--
     644my_function();
     645// --> </script><br />
     646https://youtube.com/watch?v=TEST02YRHA0<br />
     647<a href="http://www.example.com/embed/TEST03YRHA0">http://www.example.com/embed/TEST03YRHA0</a><br />
     648http://www.example.com/embed/TEST04YRHA0<br />
     649Stop.</p>
     650
     651EOF;
     652
     653                $result = apply_filters('the_content', $content );
     654                $this->assertEquals( $expected, $result );
     655        }
    588656}