ant Wed Apr 30 13:53:49 2008 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/file rename_variation3-win32.phpt rename_variation2-win32.phpt rename_variation1-win32.phpt rename_variation9.phpt rename_variation8.phpt
Modified files: /php-src/ext/standard/tests/file rename_variation-win32.phpt rename_basic.phpt Log: Break up complicated rename tests into some smaller more consumable chunks
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation-win32.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/standard/tests/file/rename_variation-win32.phpt diff -u php-src/ext/standard/tests/file/rename_variation-win32.phpt:1.1.2.1 php-src/ext/standard/tests/file/rename_variation-win32.phpt:1.1.2.2 --- php-src/ext/standard/tests/file/rename_variation-win32.phpt:1.1.2.1 Thu Jun 21 21:12:18 2007 +++ php-src/ext/standard/tests/file/rename_variation-win32.phpt Wed Apr 30 13:53:49 2008 @@ -14,7 +14,7 @@ require dirname(__FILE__).'/file.inc'; -/* creating directory */ +/* create directory */ $file_path = dirname(__FILE__); mkdir("$file_path/rename_variation"); @@ -30,7 +30,9 @@ "$file_path/rename_variation//rename_variation.tmp", "$file_path//rename_variation//rename_variation.tmp", ); + $counter = 1; + /* loop through each $file and rename it to rename_variation2.tmp */ foreach($src_filenames as $src_filename) { echo "-- Iteration $counter --\n"; @@ -38,6 +40,7 @@ fclose($fp); $dest_filename = "$file_path/rename_variation2.tmp"; var_dump( rename($src_filename, $dest_filename) ); + // ensure that file got renamed to new name var_dump( file_exists($src_filename) ); // expecting false var_dump( file_exists($dest_filename) ); // expecting true @@ -47,90 +50,8 @@ unlink($dest_filename); } -// clean the temp dir and file rmdir("$file_path/rename_variation"); -// rename dirs across directories -echo "\n*** Testing rename() : renaming directory across directories ***\n"; -$src_dirs = array ( - /* Testing simple directory tree */ - "$file_path/rename_variation/", - - /* Testing a dir with trailing slash */ - "$file_path/rename_variation/", - - /* Testing dir with double trailing slashes */ - "$file_path//rename_variation//", -); - -$dest_dir = "$file_path/rename_variation_dir"; -// create the $dest_dir -mkdir($dest_dir); - -$counter = 1; -/* loop through each $src_dirs and rename it to $dest_dir */ -foreach($src_dirs as $src_dir) { - echo "-- Iteration $counter --\n"; - - // create the src dir - mkdir("$file_path/rename_variation/"); - // rename the src dir to a new dir in dest dir - var_dump( rename($src_dir, $dest_dir."/new_dir") ); - // ensure that dir was renamed - var_dump( file_exists($src_dir) ); // expecting false - var_dump( file_exists($dest_dir."/new_dir") ); // expecting true - - // remove the new dir - rmdir($dest_dir."/new_dir"); - $counter++; -} - -/* 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_variation.tmp", "w"); -fclose($fp); -// renaming existing file to numeric name -var_dump( rename($file_path."/rename_variation.tmp", $file_path."/12345") ); -// ensure that rename worked fine -var_dump( file_exists($file_path."/rename_variation.tmp" ) ); // expecting false -var_dump( file_exists($file_path."/12345" ) ); // expecting true -// remove the file -unlink($file_path."/12345"); - -// renaming a directory to numeric name -var_dump( rename($file_path."/rename_variation_dir/", $file_path."/12345") ); -// ensure that rename worked fine -var_dump( file_exists($file_path."/rename_variation_dir" ) ); // expecting false -var_dump( file_exists($file_path."/12345" ) ); // expecting true - -// delete the file and dir -rmdir($file_path."/12345"); - -/* test rename() by trying to rename an existing file/dir to the same name - and one another */ -// create a dir -$file_path = dirname(__FILE__); -$dirname = "$file_path/rename_variation_dir"; -mkdir($dirname); -//create a file -$filename = "$file_path/rename_variation.tmp"; -$fp = fopen($filename, "w"); -fclose($fp); - -echo "\n-- Renaming file to same file name --\n"; -var_dump( rename($filename, $filename) ); - -echo "\n-- Renaming directory to same directory name --\n"; -var_dump( rename($dirname, $dirname) ); - -echo "\n-- Renaming existing file to existing directory name --\n"; -var_dump( rename($filename, $dirname) ); - -echo "\n-- Renaming existing directory to existing file name --\n"; -$fp = fopen($filename, "w"); -fclose($fp); -var_dump( rename($dirname, $filename) ); - echo "Done\n"; ?> --CLEAN-- @@ -147,53 +68,20 @@ bool(false) bool(true) -- Iteration 2 -- -bool(true) -bool(false) -bool(true) --- Iteration 3 -- -bool(true) -bool(false) -bool(true) --- Iteration 4 -- -bool(true) -bool(false) -bool(true) -*** Testing rename() : renaming directory across directories *** --- Iteration 1 -- -bool(true) +Warning: rename(%s/rename_variation/rename_variation.tmp/,%s/rename_variation2.tmp): Invalid argument in %s on line %d bool(false) bool(true) --- Iteration 2 -- -bool(true) -bool(false) -bool(true) --- Iteration 3 -- -bool(true) bool(false) -bool(true) -*** Testing rename() by renaming a file and directory to numeric name *** +Warning: unlink(%s/rename_variation2.tmp): No such file or directory in %s on line %d +-- Iteration 3 -- bool(true) bool(false) bool(true) +-- Iteration 4 -- bool(true) bool(false) bool(true) +Done --- Renaming file to same file name -- -bool(true) - --- Renaming directory to same directory name -- -bool(true) - --- Renaming existing file to existing directory name -- - -Warning: rename(%s,%s): File exists in %s on line %d -bool(false) - --- Renaming existing directory to existing file name -- - -Warning: rename(%s,%s): File exists in %s on line %d -bool(false) -Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_basic.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/standard/tests/file/rename_basic.phpt diff -u php-src/ext/standard/tests/file/rename_basic.phpt:1.1.2.1 php-src/ext/standard/tests/file/rename_basic.phpt:1.1.2.2 --- php-src/ext/standard/tests/file/rename_basic.phpt:1.1.2.1 Thu Jun 14 20:12:58 2007 +++ php-src/ext/standard/tests/file/rename_basic.phpt Wed Apr 30 13:53:49 2008 @@ -6,7 +6,7 @@ Description: Renames a file or directory */ -echo "*** Testing rename() for basic functions on existing file ***\n"; +echo "*** Testing rename() on non-existing file ***\n"; $file_path = dirname(__FILE__); $src_name = "$file_path/rename_basic.tmp"; $dest_name = "$file_path/rename_basic_new.tmp"; @@ -16,103 +16,30 @@ $s1 = stat($src_name); fclose($fp); -var_dump( rename($src_name, $dest_name) ); -// ensure that $dest_name didn't get created -var_dump( file_exists($src_name) ); // expecting false +var_dump( rename($src_name, $dest_name) ); // expecting true +var_dump( file_exists($src_name) ); // expecting false var_dump( file_exists($dest_name) ); // expecting true $s2 = stat("$file_path/rename_basic_new.tmp"); -// checking statistics of old and renamed file -// both should be same + +// checking statistics of old and renamed file - both should be same for ($i = 0; $i <= 12; $i++) { if ($s1[$i] != $s2[$i]) { echo "rename_basic.tmp and rename_basic_new.tmp stat differ at element $i\n"; } } -echo "\n*** Testing rename() on non-existing file ***\n"; -// try renaming a non existing file -$src_name = $file_path."/non_existent_file.tmp"; -$dest_name = $file_path."/rename_basic_new1.tmp"; -var_dump( rename($src_name, $dest_name) ); -// ensure that $dest_name didn't get created -var_dump( file_exists($src_name) ); // expecting false -var_dump( file_exists($dest_name) ); // expecting false - -// rename a existing dir to new name -echo "\n*** Testing rename() on existing directory ***\n"; -$dir_name = $file_path."/rename_basic_dir"; -mkdir($dir_name); -$new_dir_name = $file_path."/rename_basic_dir1"; -var_dump( rename($dir_name, $new_dir_name) ); -//ensure that $new_dir_name got created -var_dump( file_exists($dir_name) ); // expecting false -var_dump( file_exists($new_dir_name) ); // expecting true - -// try to rename an non_existing dir -echo "\n*** Testing rename() on non-existing directory ***\n"; -$non_existent_dir_name = $file_path."/non_existent_dir"; -$new_dir_name = "$file_path/rename_basic_dir2"; -var_dump( rename($non_existent_dir_name, $new_dir_name) ); -// ensure that $new_dir_name didn't get created -var_dump( file_exists($non_existent_dir_name) ); // expecting flase -var_dump( file_exists($new_dir_name) ); // expecting false - -echo "\n*** Testing rename() by giving stream context as third argument ***\n"; -$context = stream_context_create(); -// on directory -$dir_name = "$file_path/rename_basic_dir1"; -$new_dir_name = "$file_path/rename_basic_dir3"; -var_dump( rename($dir_name, $new_dir_name, $context) ); -// ensure that $new_dir_name got created -var_dump( file_exists($dir_name) ); // expecting flase -var_dump( file_exists($new_dir_name) ); // expecting true - -//on file -$src_name = "$file_path/rename_basic_new.tmp"; -$dest_name = "$file_path/rename_basic_new2.tmp"; -var_dump( rename($src_name, $dest_name, $context) ); -// ensure that $dest_name got created -var_dump( file_exists($src_name) ); // expecting false -var_dump( file_exists($dest_name) ); // expecting true - echo "Done\n"; ?> --CLEAN-- <?php -unlink(dirname(__FILE__)."/rename_basic_new2.tmp"); -rmdir(dirname(__FILE__)."/rename_basic_dir3"); +unlink(dirname(__FILE__)."/rename_basic.tmp"); +unlink(dirname(__FILE__)."/rename_basic_new.tmp"); ?> --EXPECTF-- -*** Testing rename() for basic functions on existing file *** -bool(true) -bool(false) -bool(true) - *** Testing rename() on non-existing file *** - -Warning: rename(%s/non_existent_file.tmp,%s/rename_basic_new1.tmp): No such file or directory in %s on line %d -bool(false) -bool(false) -bool(false) - -*** Testing rename() on existing directory *** -bool(true) -bool(false) -bool(true) - -*** Testing rename() on non-existing directory *** - -Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): No such file or directory in %s on line %d -bool(false) -bool(false) -bool(false) - -*** Testing rename() by giving stream context as third argument *** -bool(true) -bool(false) -bool(true) bool(true) bool(false) bool(true) Done + http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation3-win32.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/rename_variation3-win32.phpt +++ php-src/ext/standard/tests/file/rename_variation3-win32.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation2-win32.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/rename_variation2-win32.phpt +++ php-src/ext/standard/tests/file/rename_variation2-win32.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation1-win32.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/rename_variation1-win32.phpt +++ php-src/ext/standard/tests/file/rename_variation1-win32.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation9.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/rename_variation9.phpt +++ php-src/ext/standard/tests/file/rename_variation9.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation8.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/rename_variation8.phpt +++ php-src/ext/standard/tests/file/rename_variation8.phpt
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php