diff options
author | Raghubansh Kumar <kraghuba@php.net> | 2007-07-21 17:27:45 +0000 |
---|---|---|
committer | Raghubansh Kumar <kraghuba@php.net> | 2007-07-21 17:27:45 +0000 |
commit | aeac0426f5a03c99b7a44c239acd2fd6cdfad212 (patch) | |
tree | c88247c2686a3589fb7d89cbb5c3db3e91a09e5d | |
parent | cde94cb7b1d56b7c9773eece0ef006661db4102f (diff) | |
download | php-git-aeac0426f5a03c99b7a44c239acd2fd6cdfad212.tar.gz |
New testcases for lstat() and stat() functions
-rwxr-xr-x | ext/standard/tests/file/lstat_stat_variation1.phpt | 133 | ||||
-rwxr-xr-x | ext/standard/tests/file/lstat_stat_variation2.phpt | 142 | ||||
-rwxr-xr-x | ext/standard/tests/file/lstat_stat_variation3.phpt | 123 | ||||
-rwxr-xr-x | ext/standard/tests/file/lstat_stat_variation4.phpt | 194 | ||||
-rwxr-xr-x | ext/standard/tests/file/lstat_stat_variation5.phpt | 135 | ||||
-rwxr-xr-x | ext/standard/tests/file/lstat_stat_variation6.phpt | 763 |
6 files changed, 1490 insertions, 0 deletions
diff --git a/ext/standard/tests/file/lstat_stat_variation1.phpt b/ext/standard/tests/file/lstat_stat_variation1.phpt new file mode 100755 index 0000000000..c1b1be6580 --- /dev/null +++ b/ext/standard/tests/file/lstat_stat_variation1.phpt @@ -0,0 +1,133 @@ +--TEST-- +Test lstat() and stat() functions: usage variations - effects of rename() +--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 +*/ + +/* test the effects of rename() on stats of dir/file/link */ + +$file_path = dirname(__FILE__); +require "$file_path/file.inc"; + +/* create temp file, link and directory */ +mkdir("$file_path/lstat_stat_variation1/"); // temp dir +$fp = fopen("$file_path/lstat_stat_variation1.tmp", "w"); // temp file +fclose($fp); + +// temp link +symlink("$file_path/lstat_stat_variation1.tmp", "$file_path/lstat_stat_variation_link1.tmp"); + +echo "*** Checking lstat() and stat() on file, link and directory ater renaming them ***\n"; + +// renaming a file +echo "-- Testing stat() for files after being renamed --\n"; +$file_path = dirname(__FILE__); +$old_filename = "$file_path/lstat_stat_variation1.tmp"; +$new_filename = "$file_path/lstat_stat_variation1a.tmp"; +$old_stat = stat($old_filename); +clearstatcache(); +var_dump( rename($old_filename, $new_filename) ); +$new_stat = stat($new_filename); + +// compare the self stat +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); + +// compare the two stats +var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) ); +// clear the cache +clearstatcache(); + +// renaming a directory +echo "-- Testing stat() for directory after being renamed --\n"; +$old_dirname = "$file_path/lstat_stat_variation1"; +$new_dirname = "$file_path/lstat_stat_variation1a"; +$old_stat = stat($old_dirname); +clearstatcache(); +var_dump( rename($old_dirname, $new_dirname) ); +$new_stat = stat($new_dirname); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); + +// compare the two stats +var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) ); +// clear the cache +clearstatcache(); + +// renaming a link +echo "-- Testing lstat() for link after being renamed --\n"; +$old_linkname = "$file_path/lstat_stat_variation_link1.tmp"; +$new_linkname = "$file_path/lstat_stat_variation_link1a.tmp"; +$old_stat = lstat($old_linkname); +clearstatcache(); +var_dump( rename($old_linkname, $new_linkname) ); +$new_stat = lstat($new_linkname); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); + +// compare the two stats +var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) ); + +echo "\n--- Done ---"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_variation1a.tmp"); +rmdir("$file_path/lstat_stat_variation1a"); +unlink("$file_path/lstat_stat_variation_link1a.tmp"); +?> +--EXPECTF-- +*** Checking lstat() and stat() on file, link and directory ater renaming them *** +-- Testing stat() for files after being renamed -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing stat() for directory after being renamed -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing lstat() for link after being renamed -- +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- +--UEXPECTF-- +*** Checking lstat() and stat() on file, link and directory ater renaming them *** +-- Testing stat() for files after being renamed -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing stat() for directory after being renamed -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing lstat() for link after being renamed -- +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- diff --git a/ext/standard/tests/file/lstat_stat_variation2.phpt b/ext/standard/tests/file/lstat_stat_variation2.phpt new file mode 100755 index 0000000000..20fc162103 --- /dev/null +++ b/ext/standard/tests/file/lstat_stat_variation2.phpt @@ -0,0 +1,142 @@ +--TEST-- +Test lstat() and stat() functions: usage variations - effects of touch() +--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 +*/ + +/* test the effects of touch() on the stats of dir/file/link */ + +$file_path = dirname(__FILE__); +require "$file_path/file.inc"; + + +/* create temp file, link and directory */ + +$dir_name = "$file_path/lstat_stat_variation2/"; +mkdir($dir_name); // temp dir +$file_name = "$file_path/lstat_stat_variation2.tmp"; +$fp = fopen($file_name, "w"); // temp file +fclose($fp); +$link_name = "$file_path/lstat_stat_variation_link2.tmp"; +symlink($file_name, $link_name); // temp link + + +echo "\n*** Checking lstat() and stat() on file, link and directory after touching them ***\n"; + +// touch a file +echo "-- Testing stat() for file after using touch() on the file --\n"; +$old_stat = stat($file_name); +// clear the cache +clearstatcache(); +sleep(2); +var_dump( touch($file_name) ); +$new_stat = stat($file_name); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); + +// compare the stat +$affected_members = array(8, 'atime'); +var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") ); +// clear the cache +clearstatcache(); + + +// touch a directory +echo "-- Testing stat() for directory after using touch() on the directory --\n"; +$old_stat = stat($dir_name); +// clear the cache +clearstatcache(); +sleep(2); +var_dump( touch($dir_name) ); +$new_stat = stat($dir_name); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); + +// compare the stat +$affected_members = array(8, 9, 10, 'atime', 'mtime', 'ctime'); +var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") ); +// clear the cache +clearstatcache(); + +// touch a link +echo "-- Testing lstat() for link after using touch() on the link --\n"; +$old_stat = lstat($link_name); +// clear the cache +clearstatcache(); +sleep(2); +var_dump( touch($link_name) ); +$new_stat = lstat($link_name); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); + +// compare the stat +$affected_members = array(8, 'atime'); +var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") ); +// clear the stat +clearstatcache(); + +echo "\n--- Done ---"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_variation2.tmp"); +rmdir("$file_path/lstat_stat_variation2"); +unlink("$file_path/lstat_stat_variation_link2.tmp"); +?> +--EXPECTF-- +*** Checking lstat() and stat() on file, link and directory after touching them *** +-- Testing stat() for file after using touch() on the file -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing stat() for directory after using touch() on the directory -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing lstat() for link after using touch() on the link -- +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- +--UEXPECTF-- +*** Checking lstat() and stat() on file, link and directory after touching them *** +-- Testing stat() for file after using touch() on the file -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing stat() for directory after using touch() on the directory -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing lstat() for link after using touch() on the link -- +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- diff --git a/ext/standard/tests/file/lstat_stat_variation3.phpt b/ext/standard/tests/file/lstat_stat_variation3.phpt new file mode 100755 index 0000000000..7bc26de5c5 --- /dev/null +++ b/ext/standard/tests/file/lstat_stat_variation3.phpt @@ -0,0 +1,123 @@ +--TEST-- +Test lstat() and stat() functions: usage variations - writing data in file & creating/deleting file/subdir + +--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 +*/ + +/* test the effects on the stats for writing to a file and + creating or deleting file/subdir from a dir +*/ + +$file_path = dirname(__FILE__); +require "$file_path/file.inc"; + + +/* create temp file, link and directory */ +mkdir("$file_path/lstat_stat_variation3/"); // temp dir + +$file_name = "$file_path/lstat_stat_variation3.tmp"; +$fp = fopen($file_name, "w"); // temp file +fclose($fp); + +symlink("$file_path/lstat_stat_variation3.tmp", "$file_path/lstat_stat_variation3_link.tmp"); // temp link + +// writing to an empty file +echo "-- Testing stat() on file after data is written in it --\n"; +$fh = fopen($file_name,"w"); +$old_stat = stat($file_name); +clearstatcache(); +fwrite($fh, "Hello World"); +$new_stat = stat($file_name); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stats +$comp_arr = array(7, 12, 'size', 'blocks'); +var_dump(compare_stats($old_stat, $new_stat, $comp_arr, "<")); +clearstatcache(); + +// creating and deleting subdir and files in the dir +echo "-- Testing stat() on dir after subdir and file is created in it --\n"; +$dirname = "$file_path/lstat_stat_variation3"; +$old_stat = stat($dirname); +clearstatcache(); +sleep(2); +mkdir("$dirname/lstat_stat_variation3_subdir"); +$file_handle = fopen("$dirname/lstat_stat_variation3a.tmp", "w"); +fclose($file_handle); +$new_stat = stat($dirname); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stats +$affected_members = array(3, 9, 10, 'nlink', 'mtime', 'ctime'); +clearstatcache(); +var_dump(compare_stats($old_stat, $new_stat, $affected_members, "<")); +unlink("$dirname/lstat_stat_variation3a.tmp"); +rmdir("$dirname/lstat_stat_variation3_subdir"); + +// comparing stats after the deletion of subdir and file +echo "-- Testing stat() for comparing stats after the deletion of subdir and file --\n"; +$new_stat1 = stat($dirname); +// compare self stats +var_dump( compare_self_stat($new_stat1) ); +// compare the stats +$affected_members = array(3, 'nlink'); +var_dump(compare_stats($new_stat, $new_stat1, $affected_members, ">")); + +echo "\n--- Done ---"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_variation3.tmp"); +rmdir("$file_path/lstat_stat_variation3"); +unlink("$file_path/lstat_stat_variation3_link.tmp"); +?> +--EXPECTF-- +-- Testing stat() on file after data is written in it -- +bool(true) +bool(true) +bool(true) +-- Testing stat() on dir after subdir and file is created in it -- +bool(true) +bool(true) +bool(true) +-- Testing stat() for comparing stats after the deletion of subdir and file -- +bool(true) +bool(true) + +--- Done --- + +--UEXPECTF-- +-- Testing stat() on file after data is written in it -- + +Notice: fwrite(): 11 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +bool(true) +bool(true) +bool(true) +-- Testing stat() on dir after subdir and file is created in it -- +bool(true) +bool(true) +bool(true) +-- Testing stat() for comparing stats after the deletion of subdir and file -- +bool(true) +bool(true) + +--- Done --- + diff --git a/ext/standard/tests/file/lstat_stat_variation4.phpt b/ext/standard/tests/file/lstat_stat_variation4.phpt new file mode 100755 index 0000000000..1b8182edac --- /dev/null +++ b/ext/standard/tests/file/lstat_stat_variation4.phpt @@ -0,0 +1,194 @@ +--TEST-- +Test lstat() and stat() functions: usage variations - effects of is_dir(), is_file() and is_link() + +--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 +*/ + +/* test the effects of is_dir(), is_file() & is_link() on the stats of dir/file/link */ + +$file_path = dirname(__FILE__); +require "$file_path/file.inc"; + + +/* create temp file, link and directory */ +$dirname = "$file_path/lstat_stat_variation4"; +mkdir($dirname); // temp dir + +$filename = "$file_path/lstat_stat_variation4.tmp"; +$fp = fopen($filename, "w"); // temp file +fclose($fp); + +$linkname = "$file_path/lstat_stat_variation4_link.tmp"; +symlink($filename, $linkname); // temp link + +echo "\n*** Checking lstat() and stat() on file, link and directory after accessing it + with is_dir(), is_file() and is_link() functions ***\n"; + +// is_dir() on a directory +echo "-- Testing on Directory --\n"; +$old_stat = stat($dirname); +// clear the cache +clearstatcache(); +sleep(2); +var_dump( is_dir($dirname) ); +$new_stat = stat($dirname); + +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stat +var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) ); +// clear the stat +clearstatcache(); + + +// is_file() on a file +echo "-- Testing on file --\n"; +$old_stat = stat($filename); +// clear the stat +clearstatcache(); +sleep(2); +var_dump( is_file($filename) ); +$new_stat = stat($filename); +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stat +var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) ); +// clear the stat +clearstatcache(); + +// is_link() on a link +echo "-- Testing on link --\n"; +$linkname = "$file_path/lstat_stat_variation4_link.tmp"; +$old_stat = lstat($linkname); +// clear the stat +clearstatcache(); +sleep(2); +var_dump( is_link($linkname) ); +$new_stat = lstat($linkname); +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stat +var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) ); +// clear the stat +clearstatcache(); + +echo "\n*** Checking stat() on a file with read/write permission ***\n"; +$file_handle = fopen($filename, "w"); // create file +fclose($file_handle); +$old_stat = stat($filename); +// clear the stat +clearstatcache(); +sleep(2); +// opening file again in read mode +$file_handle = fopen($filename, "r"); // read file +fclose($file_handle); +$new_stat = stat($filename); +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stat +var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) ); +// clear the stat +clearstatcache(); + +echo "\n*** Checking lstat() and stat() on hard link ***\n"; +$linkname = "$file_path/lstat_stat_variation4_hard.tmp"; +var_dump( link($filename, $linkname) ); +$file_stat = stat($filename); +$link_stat = lstat($linkname); +// compare self stats +var_dump( compare_self_stat($file_stat) ); +var_dump( compare_self_stat($link_stat) ); +// compare the stat +var_dump( compare_stats($file_stat, $link_stat, $all_stat_keys) ); +// clear the stat +clearstatcache(); + +echo "\n--- Done ---"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_variation4_hard.tmp"); +unlink("$file_path/lstat_stat_variation4_link.tmp"); +unlink("$file_path/lstat_stat_variation4.tmp"); +rmdir("$file_path/lstat_stat_variation4"); +?> +--EXPECTF-- +*** Checking lstat() and stat() on file, link and directory after accessing it + with is_dir(), is_file() and is_link() functions *** +-- Testing on Directory -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing on file -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing on link -- +bool(true) +bool(true) +bool(true) +bool(true) + +*** Checking stat() on a file with read/write permission *** +bool(true) +bool(true) +bool(true) + +*** Checking lstat() and stat() on hard link *** +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- +--UEXPECTF-- +*** Checking lstat() and stat() on file, link and directory after accessing it + with is_dir(), is_file() and is_link() functions *** +-- Testing on Directory -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing on file -- +bool(true) +bool(true) +bool(true) +bool(true) +-- Testing on link -- +bool(true) +bool(true) +bool(true) +bool(true) + +*** Checking stat() on a file with read/write permission *** +bool(true) +bool(true) +bool(true) + +*** Checking lstat() and stat() on hard link *** +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- diff --git a/ext/standard/tests/file/lstat_stat_variation5.phpt b/ext/standard/tests/file/lstat_stat_variation5.phpt new file mode 100755 index 0000000000..f1fe0d0a1d --- /dev/null +++ b/ext/standard/tests/file/lstat_stat_variation5.phpt @@ -0,0 +1,135 @@ +--TEST-- +Test lstat() and stat() functions: usage variations - effects with changing permissions +--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 +*/ + +/* test for effects on stats with changing permissions of dir/file/link */ + +$file_path = dirname(__FILE__); +require "$file_path/file.inc"; + + +/* create temp file, link and directory */ +mkdir("$file_path/lstat_stat_variation5/"); // temp dir + +$filename = "$file_path/lstat_stat_variation5.tmp"; +$fp = fopen($filename, "w"); // temp file +fclose($fp); + +// temp link +$linkname = "$file_path/lstat_stat_variation5_link.tmp"; +symlink($filename, $linkname); + +/* Checking lstat() and stat() on file, link and directory after changing permission */ + +// checking lstat() and stat() on links +echo "\n*** Testing lstat() and stat() on links with miscelleneous file permission and content ***\n"; +$old_stat = lstat($linkname); +var_dump( chmod($linkname, 0777) ); +// clear the stat +clearstatcache(); +sleep(2); +$new_stat = lstat($linkname); +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stat +var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") ); +// clear the stat +clearstatcache(); + +// checking stat() on file +echo "\n*** Testing lstat() and stat() on file with miscelleneous file permission and content ***\n"; +$old_stat = stat($filename); +var_dump( chmod($filename, 0777) ); +// clear the stat +clearstatcache(); +sleep(2); +$new_stat = stat($filename); +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stat +$affected_members = array(10, 'ctime'); +var_dump( compare_stats($old_stat, $new_stat, $affected_members, "!=") ); +// clear the stat +clearstatcache(); // clear statement cache + +// checking stat() on directory +echo "\n*** Testing stat() on directory with miscelleneous file permission ***\n"; +$dirname = "$file_path/lstat_stat_variation5"; +$old_stat = stat($dirname); +var_dump( chmod($dirname, 0777) ); +// clear the stat +clearstatcache(); +sleep(2); +$new_stat = stat($dirname); +// compare self stats +var_dump( compare_self_stat($old_stat) ); +var_dump( compare_self_stat($new_stat) ); +// compare the stat +$affected_members = array(2, 10, 'mode', 'ctime'); +var_dump( compare_stats($old_stat, $new_stat, $affected_members, "!=") ); + +echo "\n--- Done ---"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_variation5_link.tmp"); +unlink("$file_path/lstat_stat_variation5.tmp"); +rmdir("$file_path/lstat_stat_variation5"); +?> +--EXPECTF-- +*** Testing lstat() and stat() on links with miscelleneous file permission and content *** +bool(true) +bool(true) +bool(true) +bool(true) + +*** Testing lstat() and stat() on file with miscelleneous file permission and content *** +bool(true) +bool(true) +bool(true) +bool(true) + +*** Testing stat() on directory with miscelleneous file permission *** +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- +--UEXPECTF-- +*** Testing lstat() and stat() on links with miscelleneous file permission and content *** +bool(true) +bool(true) +bool(true) +bool(true) + +*** Testing lstat() and stat() on file with miscelleneous file permission and content *** +bool(true) +bool(true) +bool(true) +bool(true) + +*** Testing stat() on directory with miscelleneous file permission *** +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- diff --git a/ext/standard/tests/file/lstat_stat_variation6.phpt b/ext/standard/tests/file/lstat_stat_variation6.phpt new file mode 100755 index 0000000000..ca14406d5c --- /dev/null +++ b/ext/standard/tests/file/lstat_stat_variation6.phpt @@ -0,0 +1,763 @@ +--TEST-- +Test lstat() and stat() functions: usage variations - dir/file/link names stored in objects +--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 +*/ + +/* test for stats when names of dir/file/link are stored in objects */ + +$file_path = dirname(__FILE__); +require "$file_path/file.inc"; + + +/* create temp file, link and directory */ +mkdir("$file_path/lstat_stat_variation6/"); // temp dir + +$fp = fopen("$file_path/lstat_stat_variation6.tmp", "w"); // temp file +fclose($fp); + +// temp link +symlink("$file_path/lstat_stat_variation6.tmp", "$file_path/lstat_stat_variation6_link.tmp"); + +/* Checking lstat() and stat() on file/link/directory where filenames, + linknames and directory names are stored in object and array */ + +echo "\n*** Testing lstat() and stat() with filename, linkname + and directory name stored inside a object ***\n"; + +// creating object with members as numeric and non-numeric filename, linkname and directory name +class object_temp { + public $var_name; + public function object_temp($name) { + $this->var_name = $name; + } +} +// directory as member +$obj1 = new object_temp("$file_path/lstat_stat_variation6/"); +$obj2 = new object_temp("$file_path/lstat_stat_variation6a/"); + +// file as member +$obj3 = new object_temp("$file_path/lstat_stat_variation6.tmp"); +$obj4 = new object_temp("$file_path/lstat_stat_variation6a.tmp"); + +// link as member +$obj5 = new object_temp("$file_path/lstat_stat_variation6_link.tmp"); +$obj6 = new object_temp("$file_path/lstat_stat_variation6a_link.tmp"); + +echo "\n-- Testing lstat() and stat() with softlink, linkname stored inside an object --\n"; + +var_dump( lstat($obj5->var_name) ); + +var_dump( symlink($obj5->var_name, $obj6->var_name) ); +var_dump( lstat($obj6->var_name) ); + +echo "\n-- Testing stat() on filename stored inside an object --\n"; +var_dump( stat($obj3->var_name) ); + +$fp = fopen("$file_path/lstat_stat_variation6a.tmp", "w"); +fclose($fp); +var_dump( stat($obj4->var_name) ); + +echo "\n-- Testing stat() on directory name stored inside an object --\n"; +var_dump( stat($obj1->var_name) ); + +mkdir("$file_path/lstat_stat_variation6a/"); +var_dump( stat($obj2->var_name) ); + +echo "\n--- Done ---"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/lstat_stat_variation6_link.tmp"); +unlink("$file_path/lstat_stat_variation6.tmp"); +rmdir("$file_path/lstat_stat_variation6"); +unlink("$file_path/lstat_stat_variation6a_link.tmp"); +unlink("$file_path/lstat_stat_variation6a.tmp"); +rmdir("$file_path/lstat_stat_variation6a/"); +?> + +--EXPECTF-- +*** Testing lstat() and stat() with filename, linkname + and directory name stored inside a object *** + +-- Testing lstat() and stat() with softlink, linkname stored inside an object -- +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) +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) +} + +-- Testing stat() on filename stored inside an object -- +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) +} + +-- Testing stat() on directory name stored inside an object -- +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) +} + +--- Done --- +--UEXPECTF-- +*** Testing lstat() and stat() with filename, linkname + and directory name stored inside a object *** + +-- Testing lstat() and stat() with softlink, linkname stored inside an object -- +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) +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) +} + +-- Testing stat() on filename stored inside an object -- +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) +} + +-- Testing stat() on directory name stored inside an object -- +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) +} + +--- Done --- |