1--TEST-- 2Test rename() function: usage variations-4 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip.. only for Linux'); 7} 8?> 9--FILE-- 10<?php 11 12$file_path = dirname(__FILE__); 13 14$dest_dir = "$file_path/rename_variation3_dir"; 15// create the $dest_dir 16mkdir($dest_dir); 17 18echo "\n*** Testing rename() on hard links ***\n"; 19$filename = $file_path."/rename_variation31.tmp"; 20@unlink($filename); 21var_dump(touch($filename)); 22 23$linkname = $file_path."/rename_variation3_hard_link1.tmp"; 24var_dump(link($filename, $linkname)); 25 26//rename the link to a new name in the same dir 27$dest_linkname = $file_path."/rename_variation3_hard_link2.tmp"; 28var_dump( rename( $filename, $dest_linkname) ); 29//ensure that link was renamed 30var_dump( file_exists($filename) ); // expecting false 31var_dump( file_exists($dest_linkname) ); // expecting true 32 33// rename a hard link across dir 34var_dump( rename($dest_linkname, $dest_dir."/rename_variation3_hard_link2.tmp") ); 35//ensure that link got renamed 36var_dump( file_exists($dest_linkname) ); // expecting false 37var_dump( file_exists($dest_dir."/rename_variation3_hard_link2.tmp") ); // expecting true 38 39// delete the link file now 40unlink($dest_dir."/rename_variation3_hard_link2.tmp"); 41 42echo "Done\n"; 43?> 44--CLEAN-- 45<?php 46$file_path = dirname(__FILE__); 47unlink($file_path."/rename_variation3_hard_link1.tmp"); 48rmdir($file_path."/rename_variation3_dir"); 49?> 50--EXPECTF-- 51*** Testing rename() on hard links *** 52bool(true) 53bool(true) 54bool(true) 55bool(false) 56bool(true) 57bool(true) 58bool(false) 59bool(true) 60Done 61