- Timestamp:
- 11/04/2021 03:22:47 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/sanitizeFileName.php
r51623 r52010 5 5 */ 6 6 class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { 7 function test_munges_extensions() {7 public function test_munges_extensions() { 8 8 // r17990 9 9 $file_name = sanitize_file_name( 'test.phtml.txt' ); … … 11 11 } 12 12 13 function test_removes_special_chars() {13 public function test_removes_special_chars() { 14 14 $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) ); 15 15 $string = 'test'; … … 24 24 * @ticket 22363 25 25 */ 26 function test_removes_accents() {26 public function test_removes_accents() { 27 27 $in = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ'; 28 28 $out = 'aaaaaaaeceeeeiiiinoooooouuuuyy'; … … 35 35 * @ticket 16330 36 36 */ 37 function test_replaces_spaces() {37 public function test_replaces_spaces() { 38 38 $urls = array( 39 39 'unencoded space.png' => 'unencoded-space.png', … … 48 48 } 49 49 50 function test_replaces_any_number_of_hyphens_with_one_hyphen() {50 public function test_replaces_any_number_of_hyphens_with_one_hyphen() { 51 51 $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t' ) ); 52 52 } 53 53 54 function test_trims_trailing_hyphens() {54 public function test_trims_trailing_hyphens() { 55 55 $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t----' ) ); 56 56 } 57 57 58 function test_replaces_any_amount_of_whitespace_with_one_hyphen() {58 public function test_replaces_any_amount_of_whitespace_with_one_hyphen() { 59 59 $this->assertSame( 'a-t', sanitize_file_name( 'a t' ) ); 60 60 $this->assertSame( 'a-t', sanitize_file_name( "a \n\n\nt" ) ); … … 64 64 * @ticket 16226 65 65 */ 66 function test_replaces_percent_sign() {66 public function test_replaces_percent_sign() { 67 67 $this->assertSame( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) ); 68 68 } 69 69 70 function test_replaces_unnamed_file_extensions() {70 public function test_replaces_unnamed_file_extensions() { 71 71 // Test filenames with both supported and unsupported extensions. 72 72 $this->assertSame( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) ); … … 74 74 } 75 75 76 function test_replaces_unnamed_file_extensionless() {76 public function test_replaces_unnamed_file_extensionless() { 77 77 // Test a filenames that becomes extensionless. 78 78 $this->assertSame( 'no-extension', sanitize_file_name( '_.no-extension' ) ); … … 82 82 * @dataProvider data_wp_filenames 83 83 */ 84 function test_replaces_invalid_utf8_characters( $input, $expected ) {84 public function test_replaces_invalid_utf8_characters( $input, $expected ) { 85 85 $this->assertSame( $expected, sanitize_file_name( $input ) ); 86 86 } 87 87 88 function data_wp_filenames() {88 public function data_wp_filenames() { 89 89 return array( 90 90 array( urldecode( '%B1myfile.png' ), 'myfile.png' ),
Note: See TracChangeset
for help on using the changeset viewer.