summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file/lstat_stat_variation2.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/file/lstat_stat_variation2.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/file/lstat_stat_variation2.phpt')
-rw-r--r--ext/standard/tests/file/lstat_stat_variation2.phpt62
1 files changed, 62 insertions, 0 deletions
diff --git a/ext/standard/tests/file/lstat_stat_variation2.phpt b/ext/standard/tests/file/lstat_stat_variation2.phpt
new file mode 100644
index 0000000..e7d704a
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation2.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of rename() on dir
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for 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_path = dirname(__FILE__);
+require("file.inc");
+
+/* create temp directory */
+mkdir("$file_path/lstat_stat_variation1/"); // temp dir
+
+// renaming a directory and check stat
+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 - all except ctime
+$keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12,
+ "dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "blksize", "blocks");
+var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) );
+// clear the cache
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/lstat_stat_variation1a");
+?>
+--EXPECTF--
+*** Testing stat() for directory after being renamed ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---