cvs: php-src /ext/standard/tests/file filesize_variation-win32.phpt filesize_variation.phpt lstat_stat_basic.phpt lstat_stat_error.phpt
rename_variation-win32.phpt rename_variation.phpt stat_basic-win32.phpt stat_error-win32.phpt
| From: | Raghubansh Kumar | Date: | Thu, 21 Jun 2007 21:14:21 +0000 |
| Subject: | cvs: php-src /ext/standard/tests/file filesize_variation-win32.phpt filesize_variation.phpt lstat_stat_basic.phpt lstat_stat_error.phpt rename_variation-win32.phpt rename_variation.phpt stat_basic-win32.phpt stat_error-win32.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-44903@lists.php.net to get a copy of this message | ||
kraghuba Thu Jun 21 21:14:21 2007 UTC
Modified files:
/php-src/ext/standard/tests/file stat_error-win32.phpt
lstat_stat_error.phpt
filesize_variation-win32.phpt
rename_variation-win32.phpt
stat_basic-win32.phpt
filesize_variation.phpt
rename_variation.phpt
lstat_stat_basic.phpt
Log:
New tests for file system handling functions
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/stat_error-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/stat_error-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/stat_error-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/stat_error-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,79 @@ +--TEST-- +Test stat() function: error conditions +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. only for Windows'); +} +?> +--FILE-- +<?php +/* + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +$file_path = dirname(__FILE__); +$arr = array(__FILE__); + +echo "\n*** Testing stat() for error conditions ***\n"; +var_dump( stat() ); // args < expected +var_dump( stat(__FILE__, 2) ); // file, args > expected +var_dump( stat(dirname(__FILE__), 2) ); //dir, args > expected + +var_dump( stat("$file_path/temp.tmp") ); // non existing file +var_dump( stat("$file_path/temp/") ); // non existing dir +var_dump( stat(22) ); // scalar argument +var_dump( stat($arr) ); // array argument + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done + +--UEXPECTF-- +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/lstat_stat_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/lstat_stat_error.phpt diff -u /dev/null php-src/ext/standard/tests/file/lstat_stat_error.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/lstat_stat_error.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,120 @@ +--TEST-- +Test lstat() and stat() functions: error conditions +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. lstat() not available on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: array lstat ( string $filename ); + Description: Gives information about a file or symbolic link + + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +echo "*** Testing lstat() for error conditions ***\n"; +$file_path = dirname(__FILE__); +var_dump( lstat() ); // args < expected +var_dump( lstat(__FILE__, 2) ); // args > expected +var_dump( lstat("$file_path/temp.tmp") ); // non existing file +var_dump( lstat(22) ); // scalar argument +$arr = array(__FILE__); +var_dump( lstat($arr) ); // array argument + +echo "\n*** Testing stat() for error conditions ***\n"; +var_dump( stat() ); // args < expected +var_dump( stat(__FILE__, 2) ); // file, args > expected +var_dump( stat(dirname(__FILE__), 2) ); //dir, args > expected + +var_dump( stat("$file_path/temp.tmp") ); // non existing file +var_dump( stat("$file_path/temp/") ); // non existing dir +var_dump( stat(22) ); // scalar argument +var_dump( stat($arr) ); // array argument + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing lstat() for error conditions *** + +Warning: lstat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: lstat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: lstat(): Lstat failed for %s in %s on line %d +bool(false) + +Warning: lstat(): Lstat failed for 22 in %s on line %d +bool(false) + +Warning: lstat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing lstat() for error conditions *** + +Warning: lstat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: lstat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: lstat(): Lstat failed for %s in %s on line %d +bool(false) + +Warning: lstat(): Lstat failed for 22 in %s on line %d +bool(false) + +Warning: lstat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/filesize_variation-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/filesize_variation-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/filesize_variation-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/filesize_variation-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,301 @@ +--TEST-- +Test filesize() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip only valid for Windows'); +} +--FILE-- +<?php +/* + Prototype : int filesize ( string $filename ); + Description : Returns the size of the file in bytes, or FALSE + (and generates an error of level E_WARNING) in case of an error. +*/ + +$file_path = dirname(__FILE__); +require($file_path."/file.inc"); + +echo "*** Testing filesize(): usage variations ***\n"; + +echo "*** Checking filesize() with different size of files ***\n"; +for($size = 1; $size <10000; $size = $size+1000) +{ + create_files($file_path, 1, "numeric", 0755, $size, "w", "filesize_variation"); + var_dump( filesize( $file_path."/filesize_variation1.tmp") ); + clearstatcache(); + delete_files($file_path, 1, "filesize_variation"); +} + +echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n"; +echo "-- Creating a base dir, and checking its size --\n"; +mkdir( $file_path."/filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); + +echo "-- Creating a file inside base dir, and checking dir & file size --\n"; +create_files($file_path."/filesize_variation", 1, "numeric", 0755, 1, "w", "filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation1.tmp")); +clearstatcache(); +delete_files($file_path."/filesize_variation", 1, "filesize_variation"); + +echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n"; +mkdir( $file_path."/filesize_variation/filesize_variation_sub"); +var_dump( filesize( $file_path."/filesize_variation")); // size of base dir +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); // size of subdir +clearstatcache(); + +echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n"; +// create only the file, as base and subdir is already created +$filename = $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"; +$file_handle = fopen($filename, "w"); +fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes +fclose($file_handle); +// size of base dir +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +// size of subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); +clearstatcache(); +// size of file inside subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp")); +clearstatcache(); + +echo "-- Testing filesize() after truncating the file to a new length --\n"; +// truncate the file created earlier in subdir, the size of the file is 12000bytes +// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes, +// until -1200bytes size +for($size = filesize($filename); $size>=-1200; $size-=1200) { + $file_handle = fopen($filename, "r+"); + var_dump( ftruncate($file_handle, $size) ); + fclose($file_handle); + var_dump( filesize($filename) ); + clearstatcache(); +} + +echo "-- Testing filesize() with the data of possible chars --\n"; +$filename2 = $file_path."/filesize_variation1.tmp"; +$string = "Test 2 test the filesize() fn, with data containing all the types like !@@##$%^&*():<>?|~+!;',.\][{}(special) chars, 12345(numeric) chars, and \n(newline char), \t(tab), \0, \r and so on........\0"; +echo "-- opening the file in 'w' mode and get the size --\n"; +$file_handle = fopen($filename2, "w"); +var_dump( strlen($string) ); //strlen of the string +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = strlen of string +clearstatcache(); + +echo "-- opening the file in 'wt' mode and get the size --\n"; +$file_handle = fopen($filename2, "wt"); +var_dump( strlen($string) ); //strlen of the string = 191 bytes +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = 192 bytes != strlen of string +clearstatcache(); + +echo "-- opening the file in 'a' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello, world"); +fclose($file_handle); +var_dump( filesize($filename2) ); //204 bytes +clearstatcache(); + +echo "-- opening the file in 'at' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "at"); +fwrite($file_handle, "Hello, world\n"); +fclose($file_handle); +var_dump( filesize($filename2) ); //218 bytes +clearstatcache(); + +echo "-- creating a hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +var_dump( ftruncate($file_handle, 220) ); //creating 4 bytes of hole +fclose($file_handle); +var_dump( filesize($filename2) ); //220 bytes +clearstatcache(); + +echo "-- writing data after hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello\0"); //wrting 6 bytes of data +fclose($file_handle); +var_dump( filesize($filename2) ); //226 bytes +clearstatcache(); + +echo "-- opening the existing file in write mode --\n"; +fclose( fopen($filename2, "w") ); +var_dump( filesize($filename2) ); //0 bytes +clearstatcache(); + +echo "-- with empty file --\n"; +$filename3 = dirname(__FILE__)."/filesize_variation_empty.tmp"; +fclose( fopen($filename3, "w") ); +var_dump( filesize($filename3) ); //0 bytes + +echo "*** Done ***\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"); +rmdir($file_path."/filesize_variation/filesize_variation_sub"); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation1.tmp"); +unlink($file_path."/filesize_variation_empty.tmp"); +?> +--EXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(0) +-- Creating a file inside base dir, and checking dir & file size -- +int(0) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(0) +int(0) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- +int(0) +int(0) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'wt' mode and get the size -- +int(191) +int(192) +-- opening the file in 'a' mode, adding data and checking the file -- +int(204) +-- opening the file in 'at' mode, adding data and checking the file -- +int(218) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** +--UEXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(0) +-- Creating a file inside base dir, and checking dir & file size -- +int(0) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(0) +int(0) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- + +Notice: fwrite(): 12000 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(0) +int(0) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) + +Notice: fwrite(): 191 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(191) +-- opening the file in 'wt' mode and get the size -- +int(191) +int(192) +-- opening the file in 'a' mode, adding data and checking the file -- + +Notice: fwrite(): 12 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(204) +-- opening the file in 'at' mode, adding data and checking the file -- +int(218) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- + +Notice: fwrite(): 6 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/rename_variation-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/rename_variation-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/rename_variation-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,304 @@ +--TEST-- +Test rename() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. only for Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] ); + Description: Renames a file or directory +*/ + +require dirname(__FILE__).'/file.inc'; + +/* creating directory */ +$file_path = dirname(__FILE__); +mkdir("$file_path/rename_variation/"); + +/* Testing rename() function on files */ +echo "*** Testing variations of rename() on files ***\n"; +$files_arr = array( + "$file_path/rename_variation/rename_variation.tmp", + + /* Testing file with double slashes */ + "$file_path/rename_variation//rename_variation.tmp", + "$file_path/rename_variation/r*.tmp", + + /* Testing Binary safe */ + "$file_path/rename_variation/rename_variationx000.tmp" +); +$counter = 1; +/* loop through each $file and rename it to rename_variation2.tmp */ +foreach($files_arr as $file) { + $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w"); + fclose($fp); + echo "-- Iteration $counter --\n"; + var_dump( rename($file, "$file_path/rename_variation2.tmp") ); + $counter++; + unlink("$file_path/rename_variation2.tmp"); +} +unlink("$file_path/rename_variation/rename_variation.tmp"); +rmdir("$file_path/rename_variation/"); // deleting temp directory + +/* Testing rename() function on directories */ +echo "\n*** Testing variations of rename() on directories ***\n"; +$directories = 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//", + + /* Testing Binary safe */ + "$file_path/rename_variationx000/", + + /* Testing current directory */ + ".", + + /* Dir name as empty string */ + "", + '', + + /* Dir name as string with a space */ + " ", + ' ' +); +$counter = 1; +/* loop through each $dir and rename it to rename_variation1 */ +foreach($directories as $dir) { + mkdir("$file_path/rename_variation/"); + echo "-- Iteration $counter --\n"; + var_dump( rename($dir, "$file_path/rename_variation1/") ); + $counter++; + rmdir("$file_path/rename_variation1/"); +} + +/* Testing rename() on non-existing file and directory as first argument */ +echo "\n*** Testing rename() with non-existing file and directory ***\n"; +// renaming a non-existing file to existing file +var_dump( rename(dirname(__FILE__)."/rename_variation123.tmp", __FILE__) ); +// renaming a non-existing directory to existing directory +var_dump( rename(dirname(__FILE__)."/rename_variation123/", dirname(__FILE__)) ); + +/* Renaming a file and directory to numeric name */ +echo "\n*** Testing rename() by renaming a file and directory to numeric name ***\n"; +$fp = fopen(dirname(__FILE__)."/rename_variation.tmp", "w"); +fclose($fp); +// renaming existing file to numeric name +var_dump( rename(dirname(__FILE__)."/rename_variation.tmp", dirname(__FILE__)."/12345.tmp") ); +unlink(dirname(__FILE__)."/12345.tmp"); +// renaming existing directory to numeric name +var_dump( rename(dirname(__FILE__)."/rename_variation/", dirname(__FILE__)."/12345/") ); + +echo "\n*** Testing rename() with miscelleneous input ***\n"; +$file_path = dirname(__FILE__); +mkdir("$file_path/rename_variation"); +$fp = fopen("$file_path/rename_variation.tmp", "w"); +fclose($fp); + +echo "\n-- Renaming file to same file name --\n"; +var_dump( rename("$file_path/rename_variation.tmp", "$file_path/rename_variation.tmp") ); + +echo "\n-- Renaming directory to same directory name --\n"; +var_dump( rename("$file_path/rename_variation/", "$file_path/rename_variation/") ); + +echo "\n-- Renaming existing file to directory name --\n"; +var_dump( rename("$file_path/rename_variation.tmp", "$file_path/rename_variation/") ); + +echo "\n-- Renaming existing directory to file name --\n"; +var_dump( rename("$file_path/rename_variation", "$file_path/rename_variation.tmp") ); + +echo "Done\n"; +?> +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/12345.tmp"); +unlink(dirname(__FILE__)."/rename_variation.tmp"); +rmdir(dirname(__FILE__)."/rename_variation.tmp/"); +rmdir(dirname(__FILE__)."/rename_variation/"); +rmdir(dirname(__FILE__)."/12345/"); +?> +--EXPECTF-- +*** Testing variations of rename() on files *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: unlink(%s): No such file or directory in %s on line %d + +*** Testing variations of rename() on directories *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 5 -- + +Warning: rename(.,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 6 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 7 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 8 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 9 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d + +*** Testing rename() with non-existing file and directory *** + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +*** Testing rename() by renaming a file and directory to numeric name *** +bool(true) +bool(true) + +*** Testing rename() with miscelleneous input *** + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing file to directory name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) + +-- Renaming existing directory to file name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing variations of rename() on files *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: unlink(%s): No such file or directory in %s on line %d + +*** Testing variations of rename() on directories *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 5 -- + +Warning: rename(.,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 6 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 7 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 8 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 9 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d + +*** Testing rename() with non-existing file and directory *** + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +*** Testing rename() by renaming a file and directory to numeric name *** +bool(true) +bool(true) + +*** Testing rename() with miscelleneous input *** + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing file to directory name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) + +-- Renaming existing directory to file name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/stat_basic-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/stat_basic-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/stat_basic-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/stat_basic-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,313 @@ +--TEST-- +Test stat() function: basic functionality +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. valid only for Windows'); +} +?> +--FILE-- +<?php +/* + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +$file_path = dirname(__FILE__); +require("$file_path/file.inc"); + +echo "*** Testing stat() : basic functionality ***\n"; + +/* creating temp directory and file */ + +// creating dir +$dirname = "$file_path/stat_basic"; +mkdir($dirname); +// stat of the dir created +$dir_stat = stat($dirname); +clearstatcache(); +sleep(2); + +// creating file +$filename = "$dirname/stat_basic.tmp"; +$file_handle = fopen($filename, "w"); +fclose($file_handle); +// stat of the file created +$file_stat = stat($filename); +sleep(2); + +// now new stat of the dir after file is created +$new_dir_stat = stat($dirname); +clearstatcache(); + +// stat contains 13 different values stored twice, can be accessed using +// numeric and named keys, compare them to see they are same +echo "*** Testing stat(): validating the values stored in stat ***\n"; +// Initial stat values +var_dump( compare_self_stat($file_stat) ); //expect true +var_dump( compare_self_stat($dir_stat) ); //expect true + +// New stat values taken after creation of file +var_dump( compare_self_stat($new_dir_stat) ); // expect true + +// compare the two stat values, initial stat and stat recorded after +// creating file, also dump the value of stats +echo "*** Testing stat(): comparing stats (recorded before and after file creation) ***\n"; +echo "-- comparing difference in dir stats before and after creating file in it --\n"; +$affected_elements = array( 9, 'mtime' ); +var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true + +echo "*** Testing stat(): for the return value ***\n"; +var_dump( is_array( stat($filename) ) ); + +echo "\n---Done---"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/stat_basic/stat_basic.tmp"); +rmdir("$file_path/stat_basic"); +?> +--EXPECTF-- +*** Testing stat() : basic functionality *** +*** Testing stat(): validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +*** Testing stat(): comparing stats (recorded before and after file creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(-1) + ["blocks"]=> + int(-1) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(-1) + ["blocks"]=> + int(-1) +} +bool(true) +*** Testing stat(): for the return value *** +bool(true) + +---Done--- + +--UEXPECTF-- +*** Testing stat() : basic functionality *** +*** Testing stat(): validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +*** Testing stat(): comparing stats (recorded before and after file creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(-1) + [u"blocks"]=> + int(-1) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(-1) + [u"blocks"]=> + int(-1) +} +bool(true) +*** Testing stat(): for the return value *** +bool(true) + +---Done--- http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/filesize_variation.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/filesize_variation.phpt diff -u /dev/null php-src/ext/standard/tests/file/filesize_variation.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/filesize_variation.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,301 @@ +--TEST-- +Test filesize() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip only valid for Linux'); +} +--FILE-- +<?php +/* + Prototype : int filesize ( string $filename ); + Description : Returns the size of the file in bytes, or FALSE + (and generates an error of level E_WARNING) in case of an error. +*/ + +$file_path = dirname(__FILE__); +require($file_path."/file.inc"); + +echo "*** Testing filesize(): usage variations ***\n"; + +echo "*** Checking filesize() with different size of files ***\n"; +for($size = 1; $size <10000; $size = $size+1000) +{ + create_files($file_path, 1, "numeric", 0755, $size, "w", "filesize_variation"); + var_dump( filesize( $file_path."/filesize_variation1.tmp") ); + clearstatcache(); + delete_files($file_path, 1, "filesize_variation"); +} + +echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n"; +echo "-- Creating a base dir, and checking its size --\n"; +mkdir( $file_path."/filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); + +echo "-- Creating a file inside base dir, and checking dir & file size --\n"; +create_files($file_path."/filesize_variation", 1, "numeric", 0755, 1, "w", "filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation1.tmp")); +clearstatcache(); +delete_files($file_path."/filesize_variation", 1, "filesize_variation"); + +echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n"; +mkdir( $file_path."/filesize_variation/filesize_variation_sub"); +var_dump( filesize( $file_path."/filesize_variation")); // size of base dir +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); // size of subdir +clearstatcache(); + +echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n"; +// create only the file, as base and subdir is already created +$filename = $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"; +$file_handle = fopen($filename, "w"); +fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes +fclose($file_handle); +// size of base dir +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +// size of subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); +clearstatcache(); +// size of file inside subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp")); +clearstatcache(); + +echo "-- Testing filesize() after truncating the file to a new length --\n"; +// truncate the file created earlier in subdir, the size of the file is 12000bytes +// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes, +// until -1200bytes size +for($size = filesize($filename); $size>=-1200; $size-=1200) { + $file_handle = fopen($filename, "r+"); + var_dump( ftruncate($file_handle, $size) ); + fclose($file_handle); + var_dump( filesize($filename) ); + clearstatcache(); +} + +echo "-- Testing filesize() with the data of possible chars --\n"; +$filename2 = $file_path."/filesize_variation1.tmp"; +$string = "Test 2 test the filesize() fn, with data containing all the types like !@@##$%^&*():<>?|~+!;',.\][{}(special) chars, 12345(numeric) chars, and \n(newline char), \t(tab), \0, \r and so on........\0"; +echo "-- opening the file in 'w' mode and get the size --\n"; +$file_handle = fopen($filename2, "w"); +var_dump( strlen($string) ); //strlen of the string +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = strlen of string +clearstatcache(); + +echo "-- opening the file in 'w' mode and get the size --\n"; +$file_handle = fopen($filename2, "wt"); +var_dump( strlen($string) ); //strlen of the string = 191 bytes +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = strlen of string = 191 bytes +clearstatcache(); + +echo "-- opening the file in 'a' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello, world"); +fclose($file_handle); +var_dump( filesize($filename2) ); //203 bytes +clearstatcache(); + +echo "-- opening the file in 'at' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "at"); +fwrite($file_handle, "Hello, world\n"); +fclose($file_handle); +var_dump( filesize($filename2) ); //216 bytes +clearstatcache(); + +echo "-- creating a hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +var_dump( ftruncate($file_handle, 220) ); //creating 4 bytes of hole +fclose($file_handle); +var_dump( filesize($filename2) ); //220 bytes +clearstatcache(); + +echo "-- writing data after hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello\0"); //wrting 6 bytes of data +fclose($file_handle); +var_dump( filesize($filename2) ); //226 bytes +clearstatcache(); + +echo "-- opening the existing file in write mode --\n"; +fclose( fopen($filename2, "w") ); +var_dump( filesize($filename2) ); //0 bytes +clearstatcache(); + +echo "-- with empty file --\n"; +$filename3 = dirname(__FILE__)."/filesize_variation_empty.tmp"; +fclose( fopen($filename3, "w") ); +var_dump( filesize($filename3) ); //0 bytes + +echo "*** Done ***\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"); +rmdir($file_path."/filesize_variation/filesize_variation_sub"); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation1.tmp"); +unlink($file_path."/filesize_variation_empty.tmp"); +?> +--EXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(4096) +-- Creating a file inside base dir, and checking dir & file size -- +int(4096) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(4096) +int(4096) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- +int(4096) +int(4096) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'a' mode, adding data and checking the file -- +int(203) +-- opening the file in 'at' mode, adding data and checking the file -- +int(216) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** +--UEXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(4096) +-- Creating a file inside base dir, and checking dir & file size -- +int(4096) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(4096) +int(4096) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- + +Notice: fwrite(): 12000 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(4096) +int(4096) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) + +Notice: fwrite(): 191 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(191) +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'a' mode, adding data and checking the file -- + +Notice: fwrite(): 12 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(203) +-- opening the file in 'at' mode, adding data and checking the file -- +int(216) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- + +Notice: fwrite(): 6 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/rename_variation.phpt diff -u /dev/null php-src/ext/standard/tests/file/rename_variation.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/rename_variation.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,408 @@ +--TEST-- +Test rename() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. only for Linux'); +} +?> +--FILE-- +<?php +/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] ); + Description: Renames a file or directory +*/ + +require dirname(__FILE__).'/file.inc'; + +/* creating directory */ +$file_path = dirname(__FILE__); +mkdir("$file_path/rename_variation"); + +/* rename files across directories */ +echo "*** Testing rename() : rename files across directories ***\n"; +$src_filenames = array( + "$file_path/rename_variation/rename_variation.tmp", + + /* Testing a file trailing slash */ + "$file_path/rename_variation/rename_variation.tmp/", + + /* Testing file with double slashes */ + "$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"; + $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w"); + 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 + $counter++; + + // unlink the file + 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++; +} + +/* Testing rename() on soft and hard links with different permissions */ +echo "\n*** Testing rename() on soft links ***\n"; +// create the file +$file_prefix = "rename_variation"; +create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $file_prefix); + +// create the soft links to the file +$filename = $file_prefix."1.tmp"; +create_links(dirname(__FILE__), $filename, 1, "soft", 1024, "rename_variation_soft_link"); + +//rename the link to a new name in the same dir +$src_linkname = "$file_path/rename_variation_soft_link1.tmp"; +$dest_linkname = "$file_path/rename_variation_soft_link2.tmp"; +var_dump( rename( $src_linkname, $dest_linkname) ); +//ensure that link was renamed +var_dump( file_exists($src_linkname) ); // expecting false +var_dump( file_exists($dest_linkname) ); // expecting true + +// rename a link across dir +var_dump( rename($dest_linkname, $dest_dir."/rename_variation_soft_link2.tmp")); +//ensure that link got renamed +var_dump( file_exists($dest_linkname) ); // expecting false +var_dump( file_exists($dest_dir."/rename_variation_soft_link2.tmp") ); // expecting true + +// delete the link file now +unlink($dest_dir."/rename_variation_soft_link2.tmp"); + +echo "\n*** Testing rename() on hard links ***\n"; +create_links(dirname(__FILE__), $filename, 1, "hard", 1024, "rename_variation_hard_link"); + +//rename the link to a new name in the same dir +$src_linkname = "$file_path/rename_variation_hard_link1.tmp"; +$dest_linkname = "$file_path/rename_variation_hard_link2.tmp"; +var_dump( rename( $src_linkname, $dest_linkname) ); +//ensure that link was renamed +var_dump( file_exists($src_linkname) ); // expecting false +var_dump( file_exists($dest_linkname) ); // expecting true + +// rename a hard link across dir +var_dump( rename($dest_linkname, $dest_dir."/rename_variation_hard_link2.tmp") ); +//ensure that link got renamed +var_dump( file_exists($dest_linkname) ); // expecting false +var_dump( file_exists($dest_dir."/rename_variation_hard_link2.tmp") ); // expecting true + +// delete the link file now +unlink($dest_dir."/rename_variation_hard_link2.tmp"); +// delete the file +delete_files(dirname(__FILE__), 1, $file_prefix); + +/* Renaming a file, link and directory to numeric name */ +echo "\n*** Testing rename() by renaming a file, link 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 + +// renaming existing link to numeric name +create_file( $file_path."/rename_variation.tmp"); +/* +symlink($file_path."/rename_variation.tmp", $file_path."/rename_variation_link.tmp"); +var_dump( rename($file_path."/rename_variation_link.tmp", $file_path."/1234") ); +// ensure that rename worked fine +var_dump( file_exists($file_path."/rename_variation_link.tmp" ) ); // expecting false +var_dump( file_exists($file_path."/1234" ) ); // expecting true +*/ +// delete the file and dir +rmdir($file_path."/12345"); + +/* test rename() by trying to rename an existing file/dir/link 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); +// create a link +$linkname = "$file_path/rename_variation_link.tmp"; +symlink($filename, $linkname); + +echo "\n-- Renaming link to same link name --\n"; +var_dump( rename($linkname, $linkname) ); + +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 link to existing directory name --\n"; +var_dump( rename($linkname, $dirname) ); +echo "\n-- Renaming existing link to existing file name --\n"; +var_dump( rename($linkname, $filename) ); + +echo "\n-- Renaming existing file to existing directory name --\n"; +var_dump( rename($filename, $dirname) ); +echo "\n-- Renaming existing file to existing link name --\n"; +var_dump( rename($filename, $linkname) ); + +echo "\n-- Renaming existing directory to existing file name --\n"; +$fp = fopen($filename, "w"); +fclose($fp); +var_dump( rename($dirname, $filename) ); +echo "\n-- Renaming existing directory to existing link name --\n"; +var_dump( rename($dirname, $linkname) ); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink($file_path."/rename_variation_link.tmp"); +unlink($file_path."/rename_variation.tmp"); +rmdir($file_path."/rename_variation_dir"); +?> +--EXPECTF-- +*** Testing rename() : rename files across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +bool(false) +bool(false) + +Warning: unlink(%s): 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) + +*** Testing rename() : renaming directory across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- +bool(true) +bool(false) +bool(true) +-- Iteration 3 -- +bool(true) +bool(false) +bool(true) + +*** Testing rename() on soft links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() on hard links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() by renaming a file, link and directory to numeric name *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +-- Renaming link to same link name -- +bool(true) + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing link to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing link to existing file name -- +bool(true) + +-- Renaming existing file to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing file to existing link name -- +bool(true) + +-- Renaming existing directory to existing file name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) + +-- Renaming existing directory to existing link name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +Done + +--UEXPECTF-- +*** Testing rename() : rename files across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +bool(false) +bool(false) + +Warning: unlink(%s): 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) + +*** Testing rename() : renaming directory across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- +bool(true) +bool(false) +bool(true) +-- Iteration 3 -- +bool(true) +bool(false) +bool(true) + +*** Testing rename() on soft links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() on hard links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() by renaming a file, link and directory to numeric name *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +-- Renaming link to same link name -- +bool(true) + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing link to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing link to existing file name -- +bool(true) + +-- Renaming existing file to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing file to existing link name -- +bool(true) + +-- Renaming existing directory to existing file name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) + +-- Renaming existing directory to existing link name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/lstat_stat_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/lstat_stat_basic.phpt diff -u /dev/null php-src/ext/standard/tests/file/lstat_stat_basic.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/lstat_stat_basic.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,545 @@ +--TEST-- +Test lstat() & stat() functions: basic functionality +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. lstat() not available on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: array lstat ( string $filename ); + Description: Gives information about a file or symbolic link + + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +$file_path = dirname(__FILE__); +require("$file_path/file.inc"); + +echo "*** Testing lstat() & stat() : basic functionality ***\n"; + +/* creating temp directory and file */ + +// creating dir +$dirname = "$file_path/lstat_stat_basic"; +mkdir($dirname); +// stat of the dir created +$dir_stat = stat($dirname); +clearstatcache(); +sleep(2); + +// creating file +$filename = "$dirname/lstat_stat_basic.tmp"; +$file_handle = fopen($filename, "w"); +fclose($file_handle); +// stat of the file created +$file_stat = stat($filename); +sleep(2); + +// now new stat of the dir after file is created +$new_dir_stat = stat($dirname); +clearstatcache(); + +// create soft link and record stat +$sym_linkname = "$file_path/lstat_stat_basic_link.tmp"; +symlink($filename, $sym_linkname); +// stat of the link created +$link_stat = lstat($sym_linkname); +sleep(2); +// new stat of the file, after a softlink to this file is created +$new_file_stat = stat($filename); +clearstatcache(); + +// stat contains 13 different values stored twice, can be accessed using +// numeric and named keys, compare them to see they are same +echo "*** Testing stat() and lstat() : validating the values stored in stat ***\n"; +// Initial stat values +var_dump( compare_self_stat($file_stat) ); //expect true +var_dump( compare_self_stat($dir_stat) ); //expect true +var_dump( compare_self_stat($link_stat) ); // expect true + +// New stat values taken after creation of file & link +var_dump( compare_self_stat($new_file_stat) ); //expect true +var_dump( compare_self_stat($new_dir_stat) ); // expect true + +// compare the two stat values, initial stat and stat recorded after +// creating files and link, also dump the value of stats +echo "*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) ***\n"; +echo "-- comparing difference in dir stats before and after creating file in it --\n"; +$affected_elements = array( 9, 10, 'mtime', 'ctime' ); +var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true + +echo "-- comparing difference in file stats before and after creating link to it --\n"; +var_dump( compare_stats($file_stat, $new_file_stat, $all_stat_keys, "==", true) ); // expect true + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_basic_link.tmp"); +unlink("$file_path/lstat_stat_basic/lstat_stat_basic.tmp"); +rmdir("$file_path/lstat_stat_basic"); +?> +--EXPECTF-- +*** Testing lstat() & stat() : basic functionality *** +*** Testing stat() and lstat() : validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +bool(true) +-- comparing difference in file stats before and after creating link to it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +bool(true) +Done +--UEXPECTF-- +*** Testing lstat() & stat() : basic functionality *** +*** Testing stat() and lstat() : validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +bool(true) +-- comparing difference in file stats before and after creating link to it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +bool(true) +Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/stat_error-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/stat_error-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/stat_error-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/stat_error-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,79 @@ +--TEST-- +Test stat() function: error conditions +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. only for Windows'); +} +?> +--FILE-- +<?php +/* + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +$file_path = dirname(__FILE__); +$arr = array(__FILE__); + +echo "\n*** Testing stat() for error conditions ***\n"; +var_dump( stat() ); // args < expected +var_dump( stat(__FILE__, 2) ); // file, args > expected +var_dump( stat(dirname(__FILE__), 2) ); //dir, args > expected + +var_dump( stat("$file_path/temp.tmp") ); // non existing file +var_dump( stat("$file_path/temp/") ); // non existing dir +var_dump( stat(22) ); // scalar argument +var_dump( stat($arr) ); // array argument + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done + +--UEXPECTF-- +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/lstat_stat_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/lstat_stat_error.phpt diff -u /dev/null php-src/ext/standard/tests/file/lstat_stat_error.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/lstat_stat_error.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,120 @@ +--TEST-- +Test lstat() and stat() functions: error conditions +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. lstat() not available on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: array lstat ( string $filename ); + Description: Gives information about a file or symbolic link + + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +echo "*** Testing lstat() for error conditions ***\n"; +$file_path = dirname(__FILE__); +var_dump( lstat() ); // args < expected +var_dump( lstat(__FILE__, 2) ); // args > expected +var_dump( lstat("$file_path/temp.tmp") ); // non existing file +var_dump( lstat(22) ); // scalar argument +$arr = array(__FILE__); +var_dump( lstat($arr) ); // array argument + +echo "\n*** Testing stat() for error conditions ***\n"; +var_dump( stat() ); // args < expected +var_dump( stat(__FILE__, 2) ); // file, args > expected +var_dump( stat(dirname(__FILE__), 2) ); //dir, args > expected + +var_dump( stat("$file_path/temp.tmp") ); // non existing file +var_dump( stat("$file_path/temp/") ); // non existing dir +var_dump( stat(22) ); // scalar argument +var_dump( stat($arr) ); // array argument + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing lstat() for error conditions *** + +Warning: lstat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: lstat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: lstat(): Lstat failed for %s in %s on line %d +bool(false) + +Warning: lstat(): Lstat failed for 22 in %s on line %d +bool(false) + +Warning: lstat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing lstat() for error conditions *** + +Warning: lstat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: lstat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: lstat(): Lstat failed for %s in %s on line %d +bool(false) + +Warning: lstat(): Lstat failed for 22 in %s on line %d +bool(false) + +Warning: lstat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +*** Testing stat() for error conditions *** + +Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for %s in %s on line %d +bool(false) + +Warning: stat(): stat failed for 22 in %s on line %d +bool(false) + +Warning: stat() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/filesize_variation-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/filesize_variation-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/filesize_variation-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/filesize_variation-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,301 @@ +--TEST-- +Test filesize() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip only valid for Windows'); +} +--FILE-- +<?php +/* + Prototype : int filesize ( string $filename ); + Description : Returns the size of the file in bytes, or FALSE + (and generates an error of level E_WARNING) in case of an error. +*/ + +$file_path = dirname(__FILE__); +require($file_path."/file.inc"); + +echo "*** Testing filesize(): usage variations ***\n"; + +echo "*** Checking filesize() with different size of files ***\n"; +for($size = 1; $size <10000; $size = $size+1000) +{ + create_files($file_path, 1, "numeric", 0755, $size, "w", "filesize_variation"); + var_dump( filesize( $file_path."/filesize_variation1.tmp") ); + clearstatcache(); + delete_files($file_path, 1, "filesize_variation"); +} + +echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n"; +echo "-- Creating a base dir, and checking its size --\n"; +mkdir( $file_path."/filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); + +echo "-- Creating a file inside base dir, and checking dir & file size --\n"; +create_files($file_path."/filesize_variation", 1, "numeric", 0755, 1, "w", "filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation1.tmp")); +clearstatcache(); +delete_files($file_path."/filesize_variation", 1, "filesize_variation"); + +echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n"; +mkdir( $file_path."/filesize_variation/filesize_variation_sub"); +var_dump( filesize( $file_path."/filesize_variation")); // size of base dir +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); // size of subdir +clearstatcache(); + +echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n"; +// create only the file, as base and subdir is already created +$filename = $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"; +$file_handle = fopen($filename, "w"); +fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes +fclose($file_handle); +// size of base dir +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +// size of subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); +clearstatcache(); +// size of file inside subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp")); +clearstatcache(); + +echo "-- Testing filesize() after truncating the file to a new length --\n"; +// truncate the file created earlier in subdir, the size of the file is 12000bytes +// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes, +// until -1200bytes size +for($size = filesize($filename); $size>=-1200; $size-=1200) { + $file_handle = fopen($filename, "r+"); + var_dump( ftruncate($file_handle, $size) ); + fclose($file_handle); + var_dump( filesize($filename) ); + clearstatcache(); +} + +echo "-- Testing filesize() with the data of possible chars --\n"; +$filename2 = $file_path."/filesize_variation1.tmp"; +$string = "Test 2 test the filesize() fn, with data containing all the types like !@@##$%^&*():<>?|~+!;',.\][{}(special) chars, 12345(numeric) chars, and \n(newline char), \t(tab), \0, \r and so on........\0"; +echo "-- opening the file in 'w' mode and get the size --\n"; +$file_handle = fopen($filename2, "w"); +var_dump( strlen($string) ); //strlen of the string +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = strlen of string +clearstatcache(); + +echo "-- opening the file in 'wt' mode and get the size --\n"; +$file_handle = fopen($filename2, "wt"); +var_dump( strlen($string) ); //strlen of the string = 191 bytes +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = 192 bytes != strlen of string +clearstatcache(); + +echo "-- opening the file in 'a' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello, world"); +fclose($file_handle); +var_dump( filesize($filename2) ); //204 bytes +clearstatcache(); + +echo "-- opening the file in 'at' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "at"); +fwrite($file_handle, "Hello, world\n"); +fclose($file_handle); +var_dump( filesize($filename2) ); //218 bytes +clearstatcache(); + +echo "-- creating a hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +var_dump( ftruncate($file_handle, 220) ); //creating 4 bytes of hole +fclose($file_handle); +var_dump( filesize($filename2) ); //220 bytes +clearstatcache(); + +echo "-- writing data after hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello\0"); //wrting 6 bytes of data +fclose($file_handle); +var_dump( filesize($filename2) ); //226 bytes +clearstatcache(); + +echo "-- opening the existing file in write mode --\n"; +fclose( fopen($filename2, "w") ); +var_dump( filesize($filename2) ); //0 bytes +clearstatcache(); + +echo "-- with empty file --\n"; +$filename3 = dirname(__FILE__)."/filesize_variation_empty.tmp"; +fclose( fopen($filename3, "w") ); +var_dump( filesize($filename3) ); //0 bytes + +echo "*** Done ***\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"); +rmdir($file_path."/filesize_variation/filesize_variation_sub"); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation1.tmp"); +unlink($file_path."/filesize_variation_empty.tmp"); +?> +--EXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(0) +-- Creating a file inside base dir, and checking dir & file size -- +int(0) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(0) +int(0) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- +int(0) +int(0) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'wt' mode and get the size -- +int(191) +int(192) +-- opening the file in 'a' mode, adding data and checking the file -- +int(204) +-- opening the file in 'at' mode, adding data and checking the file -- +int(218) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** +--UEXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(0) +-- Creating a file inside base dir, and checking dir & file size -- +int(0) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(0) +int(0) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- + +Notice: fwrite(): 12000 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(0) +int(0) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) + +Notice: fwrite(): 191 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(191) +-- opening the file in 'wt' mode and get the size -- +int(191) +int(192) +-- opening the file in 'a' mode, adding data and checking the file -- + +Notice: fwrite(): 12 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(204) +-- opening the file in 'at' mode, adding data and checking the file -- +int(218) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- + +Notice: fwrite(): 6 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/rename_variation-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/rename_variation-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/rename_variation-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,304 @@ +--TEST-- +Test rename() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. only for Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] ); + Description: Renames a file or directory +*/ + +require dirname(__FILE__).'/file.inc'; + +/* creating directory */ +$file_path = dirname(__FILE__); +mkdir("$file_path/rename_variation/"); + +/* Testing rename() function on files */ +echo "*** Testing variations of rename() on files ***\n"; +$files_arr = array( + "$file_path/rename_variation/rename_variation.tmp", + + /* Testing file with double slashes */ + "$file_path/rename_variation//rename_variation.tmp", + "$file_path/rename_variation/r*.tmp", + + /* Testing Binary safe */ + "$file_path/rename_variation/rename_variationx000.tmp" +); +$counter = 1; +/* loop through each $file and rename it to rename_variation2.tmp */ +foreach($files_arr as $file) { + $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w"); + fclose($fp); + echo "-- Iteration $counter --\n"; + var_dump( rename($file, "$file_path/rename_variation2.tmp") ); + $counter++; + unlink("$file_path/rename_variation2.tmp"); +} +unlink("$file_path/rename_variation/rename_variation.tmp"); +rmdir("$file_path/rename_variation/"); // deleting temp directory + +/* Testing rename() function on directories */ +echo "\n*** Testing variations of rename() on directories ***\n"; +$directories = 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//", + + /* Testing Binary safe */ + "$file_path/rename_variationx000/", + + /* Testing current directory */ + ".", + + /* Dir name as empty string */ + "", + '', + + /* Dir name as string with a space */ + " ", + ' ' +); +$counter = 1; +/* loop through each $dir and rename it to rename_variation1 */ +foreach($directories as $dir) { + mkdir("$file_path/rename_variation/"); + echo "-- Iteration $counter --\n"; + var_dump( rename($dir, "$file_path/rename_variation1/") ); + $counter++; + rmdir("$file_path/rename_variation1/"); +} + +/* Testing rename() on non-existing file and directory as first argument */ +echo "\n*** Testing rename() with non-existing file and directory ***\n"; +// renaming a non-existing file to existing file +var_dump( rename(dirname(__FILE__)."/rename_variation123.tmp", __FILE__) ); +// renaming a non-existing directory to existing directory +var_dump( rename(dirname(__FILE__)."/rename_variation123/", dirname(__FILE__)) ); + +/* Renaming a file and directory to numeric name */ +echo "\n*** Testing rename() by renaming a file and directory to numeric name ***\n"; +$fp = fopen(dirname(__FILE__)."/rename_variation.tmp", "w"); +fclose($fp); +// renaming existing file to numeric name +var_dump( rename(dirname(__FILE__)."/rename_variation.tmp", dirname(__FILE__)."/12345.tmp") ); +unlink(dirname(__FILE__)."/12345.tmp"); +// renaming existing directory to numeric name +var_dump( rename(dirname(__FILE__)."/rename_variation/", dirname(__FILE__)."/12345/") ); + +echo "\n*** Testing rename() with miscelleneous input ***\n"; +$file_path = dirname(__FILE__); +mkdir("$file_path/rename_variation"); +$fp = fopen("$file_path/rename_variation.tmp", "w"); +fclose($fp); + +echo "\n-- Renaming file to same file name --\n"; +var_dump( rename("$file_path/rename_variation.tmp", "$file_path/rename_variation.tmp") ); + +echo "\n-- Renaming directory to same directory name --\n"; +var_dump( rename("$file_path/rename_variation/", "$file_path/rename_variation/") ); + +echo "\n-- Renaming existing file to directory name --\n"; +var_dump( rename("$file_path/rename_variation.tmp", "$file_path/rename_variation/") ); + +echo "\n-- Renaming existing directory to file name --\n"; +var_dump( rename("$file_path/rename_variation", "$file_path/rename_variation.tmp") ); + +echo "Done\n"; +?> +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/12345.tmp"); +unlink(dirname(__FILE__)."/rename_variation.tmp"); +rmdir(dirname(__FILE__)."/rename_variation.tmp/"); +rmdir(dirname(__FILE__)."/rename_variation/"); +rmdir(dirname(__FILE__)."/12345/"); +?> +--EXPECTF-- +*** Testing variations of rename() on files *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: unlink(%s): No such file or directory in %s on line %d + +*** Testing variations of rename() on directories *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 5 -- + +Warning: rename(.,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 6 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 7 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 8 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 9 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d + +*** Testing rename() with non-existing file and directory *** + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +*** Testing rename() by renaming a file and directory to numeric name *** +bool(true) +bool(true) + +*** Testing rename() with miscelleneous input *** + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing file to directory name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) + +-- Renaming existing directory to file name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing variations of rename() on files *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: unlink(%s): No such file or directory in %s on line %d + +*** Testing variations of rename() on directories *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 5 -- + +Warning: rename(.,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 6 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 7 -- + +Warning: rename(,%s): Permission denied in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 8 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d +-- Iteration 9 -- + +Warning: rename( ,%s): File exists in %s on line %d +bool(false) + +Warning: rmdir(%s): No such file or directory in %s on line %d + +*** Testing rename() with non-existing file and directory *** + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +Warning: rename(%s,%s): No such file or directory in %s on line %d +bool(false) + +*** Testing rename() by renaming a file and directory to numeric name *** +bool(true) +bool(true) + +*** Testing rename() with miscelleneous input *** + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing file to directory name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) + +-- Renaming existing directory to file name -- + +Warning: rename(%s,%s): File exists in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/stat_basic-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/stat_basic-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/stat_basic-win32.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/stat_basic-win32.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,313 @@ +--TEST-- +Test stat() function: basic functionality +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. valid only for Windows'); +} +?> +--FILE-- +<?php +/* + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +$file_path = dirname(__FILE__); +require("$file_path/file.inc"); + +echo "*** Testing stat() : basic functionality ***\n"; + +/* creating temp directory and file */ + +// creating dir +$dirname = "$file_path/stat_basic"; +mkdir($dirname); +// stat of the dir created +$dir_stat = stat($dirname); +clearstatcache(); +sleep(2); + +// creating file +$filename = "$dirname/stat_basic.tmp"; +$file_handle = fopen($filename, "w"); +fclose($file_handle); +// stat of the file created +$file_stat = stat($filename); +sleep(2); + +// now new stat of the dir after file is created +$new_dir_stat = stat($dirname); +clearstatcache(); + +// stat contains 13 different values stored twice, can be accessed using +// numeric and named keys, compare them to see they are same +echo "*** Testing stat(): validating the values stored in stat ***\n"; +// Initial stat values +var_dump( compare_self_stat($file_stat) ); //expect true +var_dump( compare_self_stat($dir_stat) ); //expect true + +// New stat values taken after creation of file +var_dump( compare_self_stat($new_dir_stat) ); // expect true + +// compare the two stat values, initial stat and stat recorded after +// creating file, also dump the value of stats +echo "*** Testing stat(): comparing stats (recorded before and after file creation) ***\n"; +echo "-- comparing difference in dir stats before and after creating file in it --\n"; +$affected_elements = array( 9, 'mtime' ); +var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true + +echo "*** Testing stat(): for the return value ***\n"; +var_dump( is_array( stat($filename) ) ); + +echo "\n---Done---"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/stat_basic/stat_basic.tmp"); +rmdir("$file_path/stat_basic"); +?> +--EXPECTF-- +*** Testing stat() : basic functionality *** +*** Testing stat(): validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +*** Testing stat(): comparing stats (recorded before and after file creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(-1) + ["blocks"]=> + int(-1) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(-1) + ["blocks"]=> + int(-1) +} +bool(true) +*** Testing stat(): for the return value *** +bool(true) + +---Done--- + +--UEXPECTF-- +*** Testing stat() : basic functionality *** +*** Testing stat(): validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +*** Testing stat(): comparing stats (recorded before and after file creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(-1) + [u"blocks"]=> + int(-1) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(-1) + [12]=> + int(-1) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(-1) + [u"blocks"]=> + int(-1) +} +bool(true) +*** Testing stat(): for the return value *** +bool(true) + +---Done--- http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/filesize_variation.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/filesize_variation.phpt diff -u /dev/null php-src/ext/standard/tests/file/filesize_variation.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/filesize_variation.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,301 @@ +--TEST-- +Test filesize() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip only valid for Linux'); +} +--FILE-- +<?php +/* + Prototype : int filesize ( string $filename ); + Description : Returns the size of the file in bytes, or FALSE + (and generates an error of level E_WARNING) in case of an error. +*/ + +$file_path = dirname(__FILE__); +require($file_path."/file.inc"); + +echo "*** Testing filesize(): usage variations ***\n"; + +echo "*** Checking filesize() with different size of files ***\n"; +for($size = 1; $size <10000; $size = $size+1000) +{ + create_files($file_path, 1, "numeric", 0755, $size, "w", "filesize_variation"); + var_dump( filesize( $file_path."/filesize_variation1.tmp") ); + clearstatcache(); + delete_files($file_path, 1, "filesize_variation"); +} + +echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n"; +echo "-- Creating a base dir, and checking its size --\n"; +mkdir( $file_path."/filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); + +echo "-- Creating a file inside base dir, and checking dir & file size --\n"; +create_files($file_path."/filesize_variation", 1, "numeric", 0755, 1, "w", "filesize_variation"); +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation1.tmp")); +clearstatcache(); +delete_files($file_path."/filesize_variation", 1, "filesize_variation"); + +echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n"; +mkdir( $file_path."/filesize_variation/filesize_variation_sub"); +var_dump( filesize( $file_path."/filesize_variation")); // size of base dir +clearstatcache(); +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); // size of subdir +clearstatcache(); + +echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n"; +// create only the file, as base and subdir is already created +$filename = $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"; +$file_handle = fopen($filename, "w"); +fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes +fclose($file_handle); +// size of base dir +var_dump( filesize( $file_path."/filesize_variation")); +clearstatcache(); +// size of subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub")); +clearstatcache(); +// size of file inside subdir +var_dump( filesize( $file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp")); +clearstatcache(); + +echo "-- Testing filesize() after truncating the file to a new length --\n"; +// truncate the file created earlier in subdir, the size of the file is 12000bytes +// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes, +// until -1200bytes size +for($size = filesize($filename); $size>=-1200; $size-=1200) { + $file_handle = fopen($filename, "r+"); + var_dump( ftruncate($file_handle, $size) ); + fclose($file_handle); + var_dump( filesize($filename) ); + clearstatcache(); +} + +echo "-- Testing filesize() with the data of possible chars --\n"; +$filename2 = $file_path."/filesize_variation1.tmp"; +$string = "Test 2 test the filesize() fn, with data containing all the types like !@@##$%^&*():<>?|~+!;',.\][{}(special) chars, 12345(numeric) chars, and \n(newline char), \t(tab), \0, \r and so on........\0"; +echo "-- opening the file in 'w' mode and get the size --\n"; +$file_handle = fopen($filename2, "w"); +var_dump( strlen($string) ); //strlen of the string +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = strlen of string +clearstatcache(); + +echo "-- opening the file in 'w' mode and get the size --\n"; +$file_handle = fopen($filename2, "wt"); +var_dump( strlen($string) ); //strlen of the string = 191 bytes +fwrite($file_handle, $string); +fclose($file_handle); +var_dump( filesize($filename2) ); //size of the file = strlen of string = 191 bytes +clearstatcache(); + +echo "-- opening the file in 'a' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello, world"); +fclose($file_handle); +var_dump( filesize($filename2) ); //203 bytes +clearstatcache(); + +echo "-- opening the file in 'at' mode, adding data and checking the file --\n"; +$file_handle = fopen($filename2, "at"); +fwrite($file_handle, "Hello, world\n"); +fclose($file_handle); +var_dump( filesize($filename2) ); //216 bytes +clearstatcache(); + +echo "-- creating a hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +var_dump( ftruncate($file_handle, 220) ); //creating 4 bytes of hole +fclose($file_handle); +var_dump( filesize($filename2) ); //220 bytes +clearstatcache(); + +echo "-- writing data after hole and checking the size --\n"; +$file_handle = fopen($filename2, "a"); +fwrite($file_handle, "Hello\0"); //wrting 6 bytes of data +fclose($file_handle); +var_dump( filesize($filename2) ); //226 bytes +clearstatcache(); + +echo "-- opening the existing file in write mode --\n"; +fclose( fopen($filename2, "w") ); +var_dump( filesize($filename2) ); //0 bytes +clearstatcache(); + +echo "-- with empty file --\n"; +$filename3 = dirname(__FILE__)."/filesize_variation_empty.tmp"; +fclose( fopen($filename3, "w") ); +var_dump( filesize($filename3) ); //0 bytes + +echo "*** Done ***\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation/filesize_variation_sub/filesize_variation.tmp"); +rmdir($file_path."/filesize_variation/filesize_variation_sub"); +rmdir($file_path."/filesize_variation"); +unlink($file_path."/filesize_variation1.tmp"); +unlink($file_path."/filesize_variation_empty.tmp"); +?> +--EXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(4096) +-- Creating a file inside base dir, and checking dir & file size -- +int(4096) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(4096) +int(4096) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- +int(4096) +int(4096) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'a' mode, adding data and checking the file -- +int(203) +-- opening the file in 'at' mode, adding data and checking the file -- +int(216) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** +--UEXPECTF-- +*** Testing filesize(): usage variations *** +*** Checking filesize() with different size of files *** +int(1024) +int(1025024) +int(2049024) +int(3073024) +int(4097024) +int(5121024) +int(6145024) +int(7169024) +int(8193024) +int(9217024) + +*** Testing size of a dir, sub-dir and file with filesize() *** +-- Creating a base dir, and checking its size -- +int(4096) +-- Creating a file inside base dir, and checking dir & file size -- +int(4096) +int(1024) +-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir -- +int(4096) +int(4096) +-- Creating a file inside sub-dir, and checking size of base, subdir and file created -- + +Notice: fwrite(): 12000 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(4096) +int(4096) +int(12000) +-- Testing filesize() after truncating the file to a new length -- +bool(true) +int(12000) +bool(true) +int(10800) +bool(true) +int(9600) +bool(true) +int(8400) +bool(true) +int(7200) +bool(true) +int(6000) +bool(true) +int(4800) +bool(true) +int(3600) +bool(true) +int(2400) +bool(true) +int(1200) +bool(true) +int(0) +bool(false) +int(0) +-- Testing filesize() with the data of possible chars -- +-- opening the file in 'w' mode and get the size -- +int(191) + +Notice: fwrite(): 191 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(191) +-- opening the file in 'w' mode and get the size -- +int(191) +int(191) +-- opening the file in 'a' mode, adding data and checking the file -- + +Notice: fwrite(): 12 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(203) +-- opening the file in 'at' mode, adding data and checking the file -- +int(216) +-- creating a hole and checking the size -- +bool(true) +int(220) +-- writing data after hole and checking the size -- + +Notice: fwrite(): 6 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(226) +-- opening the existing file in write mode -- +int(0) +-- with empty file -- +int(0) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/rename_variation.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/rename_variation.phpt diff -u /dev/null php-src/ext/standard/tests/file/rename_variation.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/rename_variation.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,408 @@ +--TEST-- +Test rename() function: usage variations +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. only for Linux'); +} +?> +--FILE-- +<?php +/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] ); + Description: Renames a file or directory +*/ + +require dirname(__FILE__).'/file.inc'; + +/* creating directory */ +$file_path = dirname(__FILE__); +mkdir("$file_path/rename_variation"); + +/* rename files across directories */ +echo "*** Testing rename() : rename files across directories ***\n"; +$src_filenames = array( + "$file_path/rename_variation/rename_variation.tmp", + + /* Testing a file trailing slash */ + "$file_path/rename_variation/rename_variation.tmp/", + + /* Testing file with double slashes */ + "$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"; + $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w"); + 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 + $counter++; + + // unlink the file + 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++; +} + +/* Testing rename() on soft and hard links with different permissions */ +echo "\n*** Testing rename() on soft links ***\n"; +// create the file +$file_prefix = "rename_variation"; +create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $file_prefix); + +// create the soft links to the file +$filename = $file_prefix."1.tmp"; +create_links(dirname(__FILE__), $filename, 1, "soft", 1024, "rename_variation_soft_link"); + +//rename the link to a new name in the same dir +$src_linkname = "$file_path/rename_variation_soft_link1.tmp"; +$dest_linkname = "$file_path/rename_variation_soft_link2.tmp"; +var_dump( rename( $src_linkname, $dest_linkname) ); +//ensure that link was renamed +var_dump( file_exists($src_linkname) ); // expecting false +var_dump( file_exists($dest_linkname) ); // expecting true + +// rename a link across dir +var_dump( rename($dest_linkname, $dest_dir."/rename_variation_soft_link2.tmp")); +//ensure that link got renamed +var_dump( file_exists($dest_linkname) ); // expecting false +var_dump( file_exists($dest_dir."/rename_variation_soft_link2.tmp") ); // expecting true + +// delete the link file now +unlink($dest_dir."/rename_variation_soft_link2.tmp"); + +echo "\n*** Testing rename() on hard links ***\n"; +create_links(dirname(__FILE__), $filename, 1, "hard", 1024, "rename_variation_hard_link"); + +//rename the link to a new name in the same dir +$src_linkname = "$file_path/rename_variation_hard_link1.tmp"; +$dest_linkname = "$file_path/rename_variation_hard_link2.tmp"; +var_dump( rename( $src_linkname, $dest_linkname) ); +//ensure that link was renamed +var_dump( file_exists($src_linkname) ); // expecting false +var_dump( file_exists($dest_linkname) ); // expecting true + +// rename a hard link across dir +var_dump( rename($dest_linkname, $dest_dir."/rename_variation_hard_link2.tmp") ); +//ensure that link got renamed +var_dump( file_exists($dest_linkname) ); // expecting false +var_dump( file_exists($dest_dir."/rename_variation_hard_link2.tmp") ); // expecting true + +// delete the link file now +unlink($dest_dir."/rename_variation_hard_link2.tmp"); +// delete the file +delete_files(dirname(__FILE__), 1, $file_prefix); + +/* Renaming a file, link and directory to numeric name */ +echo "\n*** Testing rename() by renaming a file, link 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 + +// renaming existing link to numeric name +create_file( $file_path."/rename_variation.tmp"); +/* +symlink($file_path."/rename_variation.tmp", $file_path."/rename_variation_link.tmp"); +var_dump( rename($file_path."/rename_variation_link.tmp", $file_path."/1234") ); +// ensure that rename worked fine +var_dump( file_exists($file_path."/rename_variation_link.tmp" ) ); // expecting false +var_dump( file_exists($file_path."/1234" ) ); // expecting true +*/ +// delete the file and dir +rmdir($file_path."/12345"); + +/* test rename() by trying to rename an existing file/dir/link 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); +// create a link +$linkname = "$file_path/rename_variation_link.tmp"; +symlink($filename, $linkname); + +echo "\n-- Renaming link to same link name --\n"; +var_dump( rename($linkname, $linkname) ); + +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 link to existing directory name --\n"; +var_dump( rename($linkname, $dirname) ); +echo "\n-- Renaming existing link to existing file name --\n"; +var_dump( rename($linkname, $filename) ); + +echo "\n-- Renaming existing file to existing directory name --\n"; +var_dump( rename($filename, $dirname) ); +echo "\n-- Renaming existing file to existing link name --\n"; +var_dump( rename($filename, $linkname) ); + +echo "\n-- Renaming existing directory to existing file name --\n"; +$fp = fopen($filename, "w"); +fclose($fp); +var_dump( rename($dirname, $filename) ); +echo "\n-- Renaming existing directory to existing link name --\n"; +var_dump( rename($dirname, $linkname) ); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink($file_path."/rename_variation_link.tmp"); +unlink($file_path."/rename_variation.tmp"); +rmdir($file_path."/rename_variation_dir"); +?> +--EXPECTF-- +*** Testing rename() : rename files across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +bool(false) +bool(false) + +Warning: unlink(%s): 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) + +*** Testing rename() : renaming directory across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- +bool(true) +bool(false) +bool(true) +-- Iteration 3 -- +bool(true) +bool(false) +bool(true) + +*** Testing rename() on soft links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() on hard links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() by renaming a file, link and directory to numeric name *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +-- Renaming link to same link name -- +bool(true) + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing link to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing link to existing file name -- +bool(true) + +-- Renaming existing file to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing file to existing link name -- +bool(true) + +-- Renaming existing directory to existing file name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) + +-- Renaming existing directory to existing link name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +Done + +--UEXPECTF-- +*** Testing rename() : rename files across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +bool(false) +bool(false) + +Warning: unlink(%s): 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) + +*** Testing rename() : renaming directory across directories *** +-- Iteration 1 -- +bool(true) +bool(false) +bool(true) +-- Iteration 2 -- +bool(true) +bool(false) +bool(true) +-- Iteration 3 -- +bool(true) +bool(false) +bool(true) + +*** Testing rename() on soft links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() on hard links *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +*** Testing rename() by renaming a file, link and directory to numeric name *** +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) + +-- Renaming link to same link name -- +bool(true) + +-- Renaming file to same file name -- +bool(true) + +-- Renaming directory to same directory name -- +bool(true) + +-- Renaming existing link to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing link to existing file name -- +bool(true) + +-- Renaming existing file to existing directory name -- + +Warning: rename(%s,%s): Is a directory in %s on line %d +bool(false) + +-- Renaming existing file to existing link name -- +bool(true) + +-- Renaming existing directory to existing file name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) + +-- Renaming existing directory to existing link name -- + +Warning: rename(%s,%s): Not a directory in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/lstat_stat_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/lstat_stat_basic.phpt diff -u /dev/null php-src/ext/standard/tests/file/lstat_stat_basic.phpt:1.2 --- /dev/null Thu Jun 21 21:14:21 2007 +++ php-src/ext/standard/tests/file/lstat_stat_basic.phpt Thu Jun 21 21:14:21 2007 @@ -0,0 +1,545 @@ +--TEST-- +Test lstat() & stat() functions: basic functionality +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. lstat() not available on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: array lstat ( string $filename ); + Description: Gives information about a file or symbolic link + + Prototype: array stat ( string $filename ); + Description: Gives information about a file +*/ + +$file_path = dirname(__FILE__); +require("$file_path/file.inc"); + +echo "*** Testing lstat() & stat() : basic functionality ***\n"; + +/* creating temp directory and file */ + +// creating dir +$dirname = "$file_path/lstat_stat_basic"; +mkdir($dirname); +// stat of the dir created +$dir_stat = stat($dirname); +clearstatcache(); +sleep(2); + +// creating file +$filename = "$dirname/lstat_stat_basic.tmp"; +$file_handle = fopen($filename, "w"); +fclose($file_handle); +// stat of the file created +$file_stat = stat($filename); +sleep(2); + +// now new stat of the dir after file is created +$new_dir_stat = stat($dirname); +clearstatcache(); + +// create soft link and record stat +$sym_linkname = "$file_path/lstat_stat_basic_link.tmp"; +symlink($filename, $sym_linkname); +// stat of the link created +$link_stat = lstat($sym_linkname); +sleep(2); +// new stat of the file, after a softlink to this file is created +$new_file_stat = stat($filename); +clearstatcache(); + +// stat contains 13 different values stored twice, can be accessed using +// numeric and named keys, compare them to see they are same +echo "*** Testing stat() and lstat() : validating the values stored in stat ***\n"; +// Initial stat values +var_dump( compare_self_stat($file_stat) ); //expect true +var_dump( compare_self_stat($dir_stat) ); //expect true +var_dump( compare_self_stat($link_stat) ); // expect true + +// New stat values taken after creation of file & link +var_dump( compare_self_stat($new_file_stat) ); //expect true +var_dump( compare_self_stat($new_dir_stat) ); // expect true + +// compare the two stat values, initial stat and stat recorded after +// creating files and link, also dump the value of stats +echo "*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) ***\n"; +echo "-- comparing difference in dir stats before and after creating file in it --\n"; +$affected_elements = array( 9, 10, 'mtime', 'ctime' ); +var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true + +echo "-- comparing difference in file stats before and after creating link to it --\n"; +var_dump( compare_stats($file_stat, $new_file_stat, $all_stat_keys, "==", true) ); // expect true + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_basic_link.tmp"); +unlink("$file_path/lstat_stat_basic/lstat_stat_basic.tmp"); +rmdir("$file_path/lstat_stat_basic"); +?> +--EXPECTF-- +*** Testing lstat() & stat() : basic functionality *** +*** Testing stat() and lstat() : validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +bool(true) +-- comparing difference in file stats before and after creating link to it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + ["dev"]=> + int(%d) + ["ino"]=> + int(%d) + ["mode"]=> + int(%d) + ["nlink"]=> + int(%d) + ["uid"]=> + int(%d) + ["gid"]=> + int(%d) + ["rdev"]=> + int(%d) + ["size"]=> + int(%d) + ["atime"]=> + int(%d) + ["mtime"]=> + int(%d) + ["ctime"]=> + int(%d) + ["blksize"]=> + int(%d) + ["blocks"]=> + int(%d) +} +bool(true) +Done +--UEXPECTF-- +*** Testing lstat() & stat() : basic functionality *** +*** Testing stat() and lstat() : validating the values stored in stat *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) *** +-- comparing difference in dir stats before and after creating file in it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +bool(true) +-- comparing difference in file stats before and after creating link to it -- +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +array(26) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) + [3]=> + int(%d) + [4]=> + int(%d) + [5]=> + int(%d) + [6]=> + int(%d) + [7]=> + int(%d) + [8]=> + int(%d) + [9]=> + int(%d) + [10]=> + int(%d) + [11]=> + int(%d) + [12]=> + int(%d) + [u"dev"]=> + int(%d) + [u"ino"]=> + int(%d) + [u"mode"]=> + int(%d) + [u"nlink"]=> + int(%d) + [u"uid"]=> + int(%d) + [u"gid"]=> + int(%d) + [u"rdev"]=> + int(%d) + [u"size"]=> + int(%d) + [u"atime"]=> + int(%d) + [u"mtime"]=> + int(%d) + [u"ctime"]=> + int(%d) + [u"blksize"]=> + int(%d) + [u"blocks"]=> + int(%d) +} +bool(true) +Done