- Timestamp:
- 02/03/2023 12:46:18 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/sanitizeFileName.php
r53562 r55209 96 96 ); 97 97 } 98 99 /** 100 * Tests that sanitize_file_name() replaces consecutive periods 101 * with a single period. 102 * 103 * @ticket 57242 104 * 105 * @dataProvider data_sanitize_file_name_should_replace_consecutive_periods_with_a_single_period 106 * 107 * @param string $filename A filename with consecutive periods. 108 * @param string $expected The expected filename after sanitization. 109 */ 110 public function test_sanitize_file_name_should_replace_consecutive_periods_with_a_single_period( $filename, $expected ) { 111 $this->assertSame( $expected, sanitize_file_name( $filename ) ); 112 } 113 114 /** 115 * Data provider for test_sanitize_file_name_should_replace_consecutive_periods_with_a_single_period(). 116 * 117 * @return array[] 118 */ 119 public function data_sanitize_file_name_should_replace_consecutive_periods_with_a_single_period() { 120 return array( 121 'consecutive periods at the start' => array( 122 'filename' => '...filename.png', 123 'expected' => 'filename.png', 124 ), 125 'consecutive periods in the middle' => array( 126 'filename' => 'file.......name.png', 127 'expected' => 'file.name_.png', 128 ), 129 'consecutive periods before the extension' => array( 130 'filename' => 'filename....png', 131 'expected' => 'filename.png', 132 ), 133 'consecutive periods after the extension' => array( 134 'filename' => 'filename.png...', 135 'expected' => 'filename.png', 136 ), 137 'consecutive periods at the start, middle, before, after the extension' => array( 138 'filename' => '.....file....name...png......', 139 'expected' => 'file.name_.png', 140 ), 141 'consecutive periods and no extension' => array( 142 'filename' => 'filename...', 143 'expected' => 'filename', 144 ), 145 ); 146 } 98 147 }
Note: See TracChangeset
for help on using the changeset viewer.