Changeset 33525 for branches/3.7/tests/phpunit/tests/media.php
- Timestamp:
- 07/31/2015 01:45:34 AM (10 years ago)
- File:
-
- 1 edited
-
branches/3.7/tests/phpunit/tests/media.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.7/tests/phpunit/tests/media.php
r25409 r33525 347 347 $this->assertEquals( $contents, $matches ); 348 348 } 349 350 /** 351 * @ticket 33016 352 */ 353 function test_multiline_cdata() { 354 global $wp_embed; 355 356 $content = <<<EOF 357 <script>// <![CDATA[ 358 _my_function('data'); 359 // ]]> 360 </script> 361 EOF; 362 363 $result = $wp_embed->autoembed( $content ); 364 $this->assertEquals( $content, $result ); 365 } 366 367 /** 368 * @ticket 33016 369 */ 370 function test_multiline_comment() { 371 global $wp_embed; 372 373 $content = <<<EOF 374 <script><!-- 375 my_function(); 376 // --> </script> 377 EOF; 378 379 $result = $wp_embed->autoembed( $content ); 380 $this->assertEquals( $content, $result ); 381 } 382 383 384 /** 385 * @ticket 33016 386 */ 387 function test_multiline_comment_with_embeds() { 388 $content = <<<EOF 389 Start. 390 [embed]http://www.youtube.com/embed/TEST01YRHA0[/embed] 391 <script><!-- 392 my_function(); 393 // --> </script> 394 http://www.youtube.com/embed/TEST02YRHA0 395 [embed]http://www.example.com/embed/TEST03YRHA0[/embed] 396 http://www.example.com/embed/TEST04YRHA0 397 Stop. 398 EOF; 399 400 $expected = <<<EOF 401 <p>Start.<br /> 402 <a href="http://www.youtube.com/embed/TEST01YRHA0">http://www.youtube.com/embed/TEST01YRHA0</a><br /> 403 <script><!-- 404 my_function(); 405 // --> </script></p> 406 <p>http://www.youtube.com/embed/TEST02YRHA0</p> 407 <p><a href="http://www.example.com/embed/TEST03YRHA0">http://www.example.com/embed/TEST03YRHA0</a></p> 408 <p>http://www.example.com/embed/TEST04YRHA0</p> 409 <p>Stop.</p> 410 411 EOF; 412 413 $result = apply_filters( 'the_content', $content ); 414 $this->assertEquals( $expected, $result ); 415 } 416 417 /** 418 * @ticket 33016 419 */ 420 function filter_wp_embed_shortcode_custom( $content, $url ) { 421 if ( 'https://www.example.com/?video=1' == $url ) { 422 $content = '@embed URL was replaced@'; 423 } 424 return $content; 425 } 426 427 /** 428 * @ticket 33016 429 */ 430 function test_oembed_explicit_media_link() { 431 global $wp_embed; 432 add_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 2 ); 433 434 $content = <<<EOF 435 https://www.example.com/?video=1 436 EOF; 437 438 $expected = <<<EOF 439 440 @embed URL was replaced@ 441 442 EOF; 443 444 $result = $wp_embed->autoembed( $content ); 445 $this->assertEquals( $expected, $result ); 446 447 $content = <<<EOF 448 <a href="https://www.example.com/?video=1">https://www.example.com/?video=1</a> 449 <script>// <![CDATA[ 450 _my_function('data'); 451 myvar = 'Hello world 452 https://www.example.com/?video=1 453 do not break this'; 454 // ]]> 455 </script> 456 EOF; 457 458 $result = $wp_embed->autoembed( $content ); 459 $this->assertEquals( $content, $result ); 460 461 remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 ); 462 } 463 349 464 }
Note: See TracChangeset
for help on using the changeset viewer.