- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/SanitizeFileName.php
r37756 r42343 12 12 13 13 function test_removes_special_chars() { 14 $special_chars = array( "?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", chr(0));15 $string = 'test';16 foreach ( $special_chars as $char ) 14 $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', chr( 0 ) ); 15 $string = 'test'; 16 foreach ( $special_chars as $char ) { 17 17 $string .= $char; 18 } 18 19 $string .= 'test'; 19 20 $this->assertEquals( 'testtest', sanitize_file_name( $string ) ); … … 27 28 function test_replace_spaces() { 28 29 $urls = array( 29 'unencoded space.png' => 'unencoded-space.png',30 'encoded-space.jpg' => 'encoded-space.jpg',31 'plus+space.jpg' => 'plusspace.jpg',30 'unencoded space.png' => 'unencoded-space.png', 31 'encoded-space.jpg' => 'encoded-space.jpg', 32 'plus+space.jpg' => 'plusspace.jpg', 32 33 'multi %20 +space.png' => 'multi-20-space.png', 33 34 ); 34 35 35 foreach ( $urls as $test => $expected ) {36 foreach ( $urls as $test => $expected ) { 36 37 $this->assertEquals( $expected, sanitize_file_name( $test ) ); 37 38 } … … 39 40 40 41 function test_replaces_any_number_of_hyphens_with_one_hyphen() { 41 $this->assertEquals( "a-t-t", sanitize_file_name("a----t----t"));42 $this->assertEquals( 'a-t-t', sanitize_file_name( 'a----t----t' ) ); 42 43 } 43 44 44 45 function test_trims_trailing_hyphens() { 45 $this->assertEquals( "a-t-t", sanitize_file_name("a----t----t----"));46 $this->assertEquals( 'a-t-t', sanitize_file_name( 'a----t----t----' ) ); 46 47 } 47 48 48 49 function test_replaces_any_amount_of_whitespace_with_one_hyphen() { 49 $this->assertEquals( "a-t", sanitize_file_name("a t"));50 $this->assertEquals( "a-t", sanitize_file_name("a \n\n\nt"));50 $this->assertEquals( 'a-t', sanitize_file_name( 'a t' ) ); 51 $this->assertEquals( 'a-t', sanitize_file_name( "a \n\n\nt" ) ); 51 52 } 52 53
Note: See TracChangeset
for help on using the changeset viewer.