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