diff --git tests/phpunit/tests/functions.php tests/phpunit/tests/functions.php
index 7c8736a..6ec9c0c 100644
|
|
|
class Tests_Functions extends WP_UnitTestCase { |
| 1161 | 1161 | return $data; |
| 1162 | 1162 | } |
| 1163 | 1163 | |
| | 1164 | /** |
| | 1165 | * Test file path validation |
| | 1166 | * |
| | 1167 | * @ticket 42016 |
| | 1168 | * @dataProvider data_test_validate_file() |
| | 1169 | * |
| | 1170 | * @param string $file File path. |
| | 1171 | * @param array $allowed_files List of allowed files. |
| | 1172 | * @param array $expected Expected results. |
| | 1173 | */ |
| | 1174 | public function test_validate_file( $file, $allowed_files, $expected ) { |
| | 1175 | $this->assertSame( $expected, validate_file( $file, $allowed_files ) ); |
| | 1176 | } |
| | 1177 | |
| | 1178 | /** |
| | 1179 | * Data provider for test_validate_file() |
| | 1180 | * |
| | 1181 | * @return array { |
| | 1182 | * @type array { |
| | 1183 | * @string string $file File path. |
| | 1184 | * @array array $allowed_files List of allowed files. |
| | 1185 | * @array array $expected Expected results. |
| | 1186 | * } |
| | 1187 | * } |
| | 1188 | */ |
| | 1189 | public function data_test_validate_file() { |
| | 1190 | return array( |
| | 1191 | array( |
| | 1192 | null, |
| | 1193 | array(), |
| | 1194 | 0, |
| | 1195 | ), |
| | 1196 | array( |
| | 1197 | '', |
| | 1198 | array(), |
| | 1199 | 0, |
| | 1200 | ), |
| | 1201 | array( |
| | 1202 | ' ', |
| | 1203 | array(), |
| | 1204 | 0, |
| | 1205 | ), |
| | 1206 | array( |
| | 1207 | '.', |
| | 1208 | array(), |
| | 1209 | 0, |
| | 1210 | ), |
| | 1211 | array( |
| | 1212 | '..', |
| | 1213 | array(), |
| | 1214 | 0, |
| | 1215 | ), |
| | 1216 | array( |
| | 1217 | './', |
| | 1218 | array(), |
| | 1219 | 0, |
| | 1220 | ), |
| | 1221 | array( |
| | 1222 | 'foo.ext', |
| | 1223 | array( 'foo.ext' ), |
| | 1224 | 0, |
| | 1225 | ), |
| | 1226 | array( |
| | 1227 | 'foo..ext', |
| | 1228 | array(), |
| | 1229 | 0, |
| | 1230 | ), |
| | 1231 | array( |
| | 1232 | '../', |
| | 1233 | array(), |
| | 1234 | 1, |
| | 1235 | ), |
| | 1236 | array( |
| | 1237 | 'c:', |
| | 1238 | array(), |
| | 1239 | 2, |
| | 1240 | ), |
| | 1241 | array( |
| | 1242 | 'foo.ext', |
| | 1243 | array( 'bar.ext' ), |
| | 1244 | 3, |
| | 1245 | ), |
| | 1246 | ); |
| | 1247 | } |
| 1164 | 1248 | } |