Changeset 33518 for branches/4.2/tests/phpunit/tests/media.php
- Timestamp:
- 07/30/2015 07:40:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.2/tests/phpunit/tests/media.php
r32365 r33518 560 560 } 561 561 562 /** 563 * @ticket 33016 564 */ 565 function test_multiline_cdata() { 566 global $wp_embed; 567 568 $content = <<<EOF 569 <script>// <![CDATA[ 570 _my_function('data'); 571 // ]]> 572 </script> 573 EOF; 574 575 $result = $wp_embed->autoembed( $content ); 576 $this->assertEquals( $content, $result ); 577 } 578 579 /** 580 * @ticket 33016 581 */ 582 function test_multiline_comment() { 583 global $wp_embed; 584 585 $content = <<<EOF 586 <script><!-- 587 my_function(); 588 // --> </script> 589 EOF; 590 591 $result = $wp_embed->autoembed( $content ); 592 $this->assertEquals( $content, $result ); 593 } 594 595 596 /** 597 * @ticket 33016 598 */ 599 function test_multiline_comment_with_embeds() { 600 $content = <<<EOF 601 Start. 602 [embed]http://www.youtube.com/embed/TEST01YRHA0[/embed] 603 <script><!-- 604 my_function(); 605 // --> </script> 606 http://www.youtube.com/embed/TEST02YRHA0 607 [embed]http://www.example.com/embed/TEST03YRHA0[/embed] 608 http://www.example.com/embed/TEST04YRHA0 609 Stop. 610 EOF; 611 612 $expected = <<<EOF 613 <p>Start.<br /> 614 https://youtube.com/watch?v=TEST01YRHA0<br /> 615 <script><!-- 616 my_function(); 617 // --> </script><br /> 618 https://youtube.com/watch?v=TEST02YRHA0<br /> 619 <a href="http://www.example.com/embed/TEST03YRHA0">http://www.example.com/embed/TEST03YRHA0</a><br /> 620 http://www.example.com/embed/TEST04YRHA0<br /> 621 Stop.</p> 622 623 EOF; 624 625 $result = apply_filters( 'the_content', $content ); 626 $this->assertEquals( $expected, $result ); 627 } 628 629 /** 630 * @ticket 33016 631 */ 632 function filter_wp_embed_shortcode_custom( $content, $url ) { 633 if ( 'https://www.example.com/?video=1' == $url ) { 634 $content = '@embed URL was replaced@'; 635 } 636 return $content; 637 } 638 639 /** 640 * @ticket 33016 641 */ 642 function test_oembed_explicit_media_link() { 643 global $wp_embed; 644 add_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 2 ); 645 646 $content = <<<EOF 647 https://www.example.com/?video=1 648 EOF; 649 650 $expected = <<<EOF 651 @embed URL was replaced@ 652 EOF; 653 654 $result = $wp_embed->autoembed( $content ); 655 $this->assertEquals( $expected, $result ); 656 657 $content = <<<EOF 658 <a href="https://www.example.com/?video=1">https://www.example.com/?video=1</a> 659 <script>// <![CDATA[ 660 _my_function('data'); 661 myvar = 'Hello world 662 https://www.example.com/?video=1 663 do not break this'; 664 // ]]> 665 </script> 666 EOF; 667 668 $result = $wp_embed->autoembed( $content ); 669 $this->assertEquals( $content, $result ); 670 671 remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 ); 672 } 562 673 }
Note: See TracChangeset
for help on using the changeset viewer.