Changeset 33521 for branches/4.1/tests/phpunit/tests/media.php
- Timestamp:
- 07/31/2015 01:42:39 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.1/tests/phpunit/tests/media.php
r33374 r33521 468 468 } 469 469 470 /** 471 * @ticket 33016 472 */ 473 function test_multiline_cdata() { 474 global $wp_embed; 475 476 $content = <<<EOF 477 <script>// <![CDATA[ 478 _my_function('data'); 479 // ]]> 480 </script> 481 EOF; 482 483 $result = $wp_embed->autoembed( $content ); 484 $this->assertEquals( $content, $result ); 485 } 486 487 /** 488 * @ticket 33016 489 */ 490 function test_multiline_comment() { 491 global $wp_embed; 492 493 $content = <<<EOF 494 <script><!-- 495 my_function(); 496 // --> </script> 497 EOF; 498 499 $result = $wp_embed->autoembed( $content ); 500 $this->assertEquals( $content, $result ); 501 } 502 503 504 /** 505 * @ticket 33016 506 */ 507 function test_multiline_comment_with_embeds() { 508 $content = <<<EOF 509 Start. 510 [embed]http://www.youtube.com/embed/TEST01YRHA0[/embed] 511 <script><!-- 512 my_function(); 513 // --> </script> 514 http://www.youtube.com/embed/TEST02YRHA0 515 [embed]http://www.example.com/embed/TEST03YRHA0[/embed] 516 http://www.example.com/embed/TEST04YRHA0 517 Stop. 518 EOF; 519 520 $expected = <<<EOF 521 <p>Start.</p> 522 <p>https://youtube.com/watch?v=TEST01YRHA0</p> 523 <p><script><!-- 524 my_function(); 525 // --> </script></p> 526 <p>https://youtube.com/watch?v=TEST02YRHA0</p> 527 <p><a href="http://www.example.com/embed/TEST03YRHA0">http://www.example.com/embed/TEST03YRHA0</a></p> 528 <p>http://www.example.com/embed/TEST04YRHA0</p> 529 <p>Stop.</p> 530 531 EOF; 532 533 $result = apply_filters( 'the_content', $content ); 534 $this->assertEquals( $expected, $result ); 535 } 536 537 /** 538 * @ticket 33016 539 */ 540 function filter_wp_embed_shortcode_custom( $content, $url ) { 541 if ( 'https://www.example.com/?video=1' == $url ) { 542 $content = '@embed URL was replaced@'; 543 } 544 return $content; 545 } 546 547 /** 548 * @ticket 33016 549 */ 550 function test_oembed_explicit_media_link() { 551 global $wp_embed; 552 add_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 2 ); 553 554 $content = <<<EOF 555 https://www.example.com/?video=1 556 EOF; 557 558 $expected = <<<EOF 559 560 @embed URL was replaced@ 561 562 EOF; 563 564 $result = $wp_embed->autoembed( $content ); 565 $this->assertEquals( $expected, $result ); 566 567 $content = <<<EOF 568 <a href="https://www.example.com/?video=1">https://www.example.com/?video=1</a> 569 <script>// <![CDATA[ 570 _my_function('data'); 571 myvar = 'Hello world 572 https://www.example.com/?video=1 573 do not break this'; 574 // ]]> 575 </script> 576 EOF; 577 578 $result = $wp_embed->autoembed( $content ); 579 $this->assertEquals( $content, $result ); 580 581 remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 ); 582 } 470 583 }
Note: See TracChangeset
for help on using the changeset viewer.