1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix rename test file name collision
This commit is contained in:
Ilija Tovilo
2024-04-15 13:43:06 +02:00

View File

@@ -11,28 +11,28 @@ if (substr(PHP_OS, 0, 3) != 'WIN') {
require __DIR__.'/file.inc';
$file_path = __DIR__;
mkdir("$file_path/rename_variation2_dir");
mkdir("$file_path/rename_variation2-win32_dir");
/* Renaming a file and directory to numeric name */
echo "\n*** Testing rename() by renaming a file and directory to numeric name ***\n";
$fp = fopen($file_path."/rename_variation2.tmp", "w");
$fp = fopen($file_path."/rename_variation2-win32.tmp", "w");
fclose($fp);
// renaming existing file to numeric name
var_dump( rename($file_path."/rename_variation2.tmp", $file_path."/12345") );
var_dump( rename($file_path."/rename_variation2-win32.tmp", $file_path."/12346") );
// ensure that rename worked fine
var_dump( file_exists($file_path."/rename_variation2.tmp" ) ); // expecting false
var_dump( file_exists($file_path."/12345" ) ); // expecting true
var_dump( file_exists($file_path."/rename_variation2-win32.tmp" ) ); // expecting false
var_dump( file_exists($file_path."/12346" ) ); // expecting true
unlink($file_path."/12345");
unlink($file_path."/12346");
// renaming a directory to numeric name
var_dump( rename($file_path."/rename_variation2_dir/", $file_path."/12345") );
var_dump( rename($file_path."/rename_variation2-win32_dir/", $file_path."/12346") );
// ensure that rename worked fine
var_dump( file_exists($file_path."/rename_variation2_dir" ) ); // expecting false
var_dump( file_exists($file_path."/12345" ) ); // expecting true
var_dump( file_exists($file_path."/rename_variation2-win32_dir" ) ); // expecting false
var_dump( file_exists($file_path."/12346" ) ); // expecting true
echo "Done\n";
?>