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