Changeset 59057 for trunk/tests/phpunit/includes/abstract-testcase.php
- Timestamp:
- 09/18/2024 06:20:43 PM (14 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/includes/abstract-testcase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r57987 r59057 1069 1069 $this->assertNotEmpty( $sub_array, $message . ' Subitem of the array is empty.' ); 1070 1070 } 1071 } 1072 1073 /** 1074 * Assert that two text strings representing file paths are the same, while ignoring 1075 * OS-specific differences in the directory separators. 1076 * 1077 * This allows for tests to be compatible for running on both *nix based as well as Windows OS. 1078 * 1079 * @since 6.7.0 1080 * 1081 * @param string $path_a File or directory path. 1082 * @param string $path_b File or directory path. 1083 */ 1084 public function assertSamePathIgnoringDirectorySeparators( $path_a, $path_b ) { 1085 $path_a = $this->normalizeDirectorySeparatorsInPath( $path_a ); 1086 $path_b = $this->normalizeDirectorySeparatorsInPath( $path_b ); 1087 1088 $this->assertSame( $path_a, $path_b ); 1089 } 1090 1091 /** 1092 * Normalize directory separators in a file path to be a forward slash. 1093 * 1094 * @since 6.7.0 1095 * 1096 * @param string $path File or directory path. 1097 * @return string The normalized file or directory path. 1098 */ 1099 public function normalizeDirectorySeparatorsInPath( $path ) { 1100 if ( ! is_string( $path ) || PHP_OS_FAMILY !== 'Windows' ) { 1101 return $path; 1102 } 1103 1104 return strtr( $path, '\\', '/' ); 1071 1105 } 1072 1106
Note: See TracChangeset
for help on using the changeset viewer.