Changeset 25313 for trunk/tests/phpunit/tests/functions.php
- Timestamp:
- 09/10/2013 03:17:51 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions.php
r25301 r25313 100 100 101 101 function test_wp_unique_filename() { 102 102 103 103 $testdir = DIR_TESTDATA . '/images/'; 104 104 105 105 // sanity check 106 106 $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcdefg.png' ), 'Sanitiy check failed' ); … … 113 113 // check special chars 114 114 $this->assertEquals( 'testtést-imagé.png', wp_unique_filename( $testdir, 'testtést-imagé.png' ), 'Filename with special chars failed' ); 115 115 116 116 // check special chars with potential conflicting name 117 117 $this->assertEquals( 'tést-imagé.png', wp_unique_filename( $testdir, 'tést-imagé.png' ), 'Filename with special chars failed' ); 118 118 119 119 // check with single quotes in name (somehow) 120 120 $this->assertEquals( "abcdefgh.png", wp_unique_filename( $testdir, "abcdefg'h.png" ), 'File with quote failed' ); … … 125 125 // test crazy name (useful for regression tests) 126 126 $this->assertEquals( '12%af34567890@..%^_+qwerty-fghjkl-zx.png', wp_unique_filename( $testdir, '12%af34567890#~!@#$..%^&*()|_+qwerty fgh`jkl zx<>?:"{}[]="\'/?.png' ), 'Failed crazy file name' ); 127 127 128 128 // test slashes in names 129 129 $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\fg.png' ), 'Slash not removed' ); … … 363 363 $this->assertNotContains( 'data', wp_allowed_protocols() ); 364 364 } 365 366 /** 367 * @ticket 9064 368 */ 369 function test_wp_extract_urls() { 370 $original_urls = array( 371 'http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html', 372 'http://this.com', 373 'http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437', 374 'http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html', 375 'http://wordpress-core.com:8080/', 376 'http://www.website.com:5000', 377 'http://wordpress-core/?346236346326&2134362574863.437', 378 'http://افغانستا.icom.museum', 379 'http://الجزائر.icom.museum', 380 'http://österreich.icom.museum', 381 'http://বাংলাদেশ.icom.museum', 382 'http://беларусь.icom.museum', 383 'http://belgië.icom.museum', 384 'http://българия.icom.museum', 385 'http://تشادر.icom.museum', 386 'http://中国.icom.museum', 387 #'http://القمر.icom.museum', // Comoros http://القمر.icom.museum 388 #'http://κυπρος.icom.museum', Cyprus http://κυπρος.icom.museum 389 'http://českárepublika.icom.museum', 390 #'http://مصر.icom.museum', // Egypt http://مصر.icom.museum 391 'http://ελλάδα.icom.museum', 392 'http://magyarország.icom.museum', 393 'http://ísland.icom.museum', 394 'http://भारत.icom.museum', 395 'http://ايران.icom.museum', 396 'http://éire.icom.museum', 397 'http://איקו״ם.ישראל.museum', 398 'http://日本.icom.museum', 399 'http://الأردن.icom.museum', 400 'http://қазақстан.icom.museum', 401 'http://한국.icom.museum', 402 'http://кыргызстан.icom.museum', 403 'http://ລາວ.icom.museum', 404 'http://لبنان.icom.museum', 405 'http://македонија.icom.museum', 406 #'http://موريتانيا.icom.museum', // Mauritania http://موريتانيا.icom.museum 407 'http://méxico.icom.museum', 408 'http://монголулс.icom.museum', 409 #'http://المغرب.icom.museum', // Morocco http://المغرب.icom.museum 410 'http://नेपाल.icom.museum', 411 #'http://عمان.icom.museum', // Oman http://عمان.icom.museum 412 'http://قطر.icom.museum', 413 'http://românia.icom.museum', 414 'http://россия.иком.museum', 415 'http://србијаицрнагора.иком.museum', 416 'http://இலங்கை.icom.museum', 417 'http://españa.icom.museum', 418 'http://ไทย.icom.museum', 419 'http://تونس.icom.museum', 420 'http://türkiye.icom.museum', 421 'http://украина.icom.museum', 422 'http://việtnam.icom.museum' 423 ); 424 425 $blob =" 426 http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html 427 428 http://this.com 429 430 http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437 431 432 http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html 433 434 http://wordpress-core.com:8080/ 435 436 http://www.website.com:5000 437 438 http://wordpress-core/?346236346326&2134362574863.437 439 440 http://افغانستا.icom.museum 441 http://الجزائر.icom.museum 442 http://österreich.icom.museum 443 http://বাংলাদেশ.icom.museum 444 http://беларусь.icom.museum 445 http://belgië.icom.museum 446 http://българия.icom.museum 447 http://تشادر.icom.museum 448 http://中国.icom.museum 449 http://českárepublika.icom.museum 450 http://ελλάδα.icom.museum 451 http://magyarország.icom.museum 452 http://ísland.icom.museum 453 http://भारत.icom.museum 454 http://ايران.icom.museum 455 http://éire.icom.museum 456 http://איקו״ם.ישראל.museum 457 http://日本.icom.museum 458 http://الأردن.icom.museum 459 http://қазақстан.icom.museum 460 http://한국.icom.museum 461 http://кыргызстан.icom.museum 462 http://ລາວ.icom.museum 463 http://لبنان.icom.museum 464 http://македонија.icom.museum 465 http://méxico.icom.museum 466 http://монголулс.icom.museum 467 http://नेपाल.icom.museum 468 http://قطر.icom.museum 469 http://românia.icom.museum 470 http://россия.иком.museum 471 http://србијаицрнагора.иком.museum 472 http://இலங்கை.icom.museum 473 http://españa.icom.museum 474 http://ไทย.icom.museum 475 http://تونس.icom.museum 476 http://türkiye.icom.museum 477 http://украина.icom.museum 478 http://việtnam.icom.museum 479 "; 480 481 $urls = wp_extract_urls( $blob ); 482 $this->assertNotEmpty( $urls ); 483 $this->assertInternalType( 'array', $urls ); 484 $this->assertCount( count( $original_urls ), $urls ); 485 $this->assertEquals( $original_urls, $urls ); 486 487 $exploded = array_values( array_filter( array_map( 'trim', explode( "\n", $blob ) ) ) ); 488 // wp_extract_urls calls html_entity_decode 489 $decoded = array_map( 'html_entity_decode', $exploded ); 490 491 $this->assertEquals( $decoded, $urls ); 492 $this->assertEquals( $original_urls, $decoded ); 493 494 $blob ="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 495 incididunt ut labore http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html et dolore magna aliqua. 496 Ut http://this.com enim ad minim veniam, quis nostrud exercitation ullamco 497 laboris nisi ut aliquip ex http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437 ea 498 commodo consequat. http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html Duis aute irure dolor in reprehenderit in voluptate 499 velit esse http://wordpress-core.com:8080/ cillum dolore eu fugiat nulla <A href=\"http://www.website.com:5000\">http://www.website.com:5000</B> pariatur. Excepteur sint occaecat cupidatat non proident, 500 sunt in culpa qui officia deserunt mollit http://wordpress-core/?346236346326&2134362574863.437 anim id est laborum."; 501 502 $urls = wp_extract_urls( $blob ); 503 $this->assertNotEmpty( $urls ); 504 $this->assertInternalType( 'array', $urls ); 505 $this->assertCount( 7, $urls ); 506 $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls ); 507 508 $blob = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 509 incididunt ut labore <a href="http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html">343462^</a> et dolore magna aliqua. 510 Ut <a href="http://this.com">&3640i6p1yi499</a> enim ad minim veniam, quis nostrud exercitation ullamco 511 laboris nisi ut aliquip ex <a href="http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437">343462^</a> ea 512 commodo consequat. <a href="http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html">343462^</a> Duis aute irure dolor in reprehenderit in voluptate 513 velit esse <a href="http://wordpress-core.com:8080/">-3-4--321-64-4@#!$^$!@^@^</a> cillum dolore eu <A href="http://www.website.com:5000">http://www.website.com:5000</B> fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, 514 sunt in culpa qui officia deserunt mollit <a href="http://wordpress-core/?346236346326&2134362574863.437">)(*&^%$</a> anim id est laborum.'; 515 516 $urls = wp_extract_urls( $blob ); 517 $this->assertNotEmpty( $urls ); 518 $this->assertInternalType( 'array', $urls ); 519 $this->assertCount( 7, $urls ); 520 $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls ); 521 } 365 522 }
Note: See TracChangeset
for help on using the changeset viewer.