stat_basic-win32.phpt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. --TEST--
  2. Test stat() function: basic functionality
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die('skip.. valid only for Windows');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /*
  12. Prototype: array stat ( string $filename );
  13. Description: Gives information about a file
  14. */
  15. $file_path = dirname(__FILE__);
  16. require("$file_path/file.inc");
  17. echo "*** Testing stat() : basic functionality ***\n";
  18. /* creating temp directory and file */
  19. // creating dir
  20. $dirname = "$file_path/stat_basic";
  21. mkdir($dirname);
  22. // stat of the dir created
  23. $dir_stat = stat($dirname);
  24. clearstatcache();
  25. sleep(2);
  26. // creating file
  27. $filename = "$dirname/stat_basic.tmp";
  28. $file_handle = fopen($filename, "w");
  29. fclose($file_handle);
  30. // stat of the file created
  31. $file_stat = stat($filename);
  32. sleep(2);
  33. // now new stat of the dir after file is created
  34. $new_dir_stat = stat($dirname);
  35. clearstatcache();
  36. // stat contains 13 different values stored twice, can be accessed using
  37. // numeric and named keys, compare them to see they are same
  38. echo "*** Testing stat(): validating the values stored in stat ***\n";
  39. // Initial stat values
  40. var_dump( compare_self_stat($file_stat) ); //expect true
  41. var_dump( compare_self_stat($dir_stat) ); //expect true
  42. // New stat values taken after creation of file
  43. var_dump( compare_self_stat($new_dir_stat) ); // expect true
  44. // compare the two stat values, initial stat and stat recorded after
  45. // creating file, also dump the value of stats
  46. echo "*** Testing stat(): comparing stats (recorded before and after file creation) ***\n";
  47. echo "-- comparing difference in dir stats before and after creating file in it --\n";
  48. $affected_elements = array( 9, 'mtime' );
  49. var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true
  50. echo "*** Testing stat(): for the return value ***\n";
  51. var_dump( is_array( stat($filename) ) );
  52. echo "\n---Done---";
  53. ?>
  54. --CLEAN--
  55. <?php
  56. $file_path = dirname(__FILE__);
  57. unlink("$file_path/stat_basic/stat_basic.tmp");
  58. rmdir("$file_path/stat_basic");
  59. ?>
  60. --EXPECTF--
  61. *** Testing stat() : basic functionality ***
  62. *** Testing stat(): validating the values stored in stat ***
  63. bool(true)
  64. bool(true)
  65. bool(true)
  66. *** Testing stat(): comparing stats (recorded before and after file creation) ***
  67. -- comparing difference in dir stats before and after creating file in it --
  68. array(26) {
  69. [0]=>
  70. int(%d)
  71. [1]=>
  72. int(0)
  73. [2]=>
  74. int(%d)
  75. [3]=>
  76. int(%d)
  77. [4]=>
  78. int(0)
  79. [5]=>
  80. int(0)
  81. [6]=>
  82. int(%d)
  83. [7]=>
  84. int(%d)
  85. [8]=>
  86. int(%d)
  87. [9]=>
  88. int(%d)
  89. [10]=>
  90. int(%d)
  91. [11]=>
  92. int(-1)
  93. [12]=>
  94. int(-1)
  95. ["dev"]=>
  96. int(%d)
  97. ["ino"]=>
  98. int(0)
  99. ["mode"]=>
  100. int(%d)
  101. ["nlink"]=>
  102. int(%d)
  103. ["uid"]=>
  104. int(0)
  105. ["gid"]=>
  106. int(0)
  107. ["rdev"]=>
  108. int(%d)
  109. ["size"]=>
  110. int(%d)
  111. ["atime"]=>
  112. int(%d)
  113. ["mtime"]=>
  114. int(%d)
  115. ["ctime"]=>
  116. int(%d)
  117. ["blksize"]=>
  118. int(-1)
  119. ["blocks"]=>
  120. int(-1)
  121. }
  122. array(26) {
  123. [0]=>
  124. int(%d)
  125. [1]=>
  126. int(%d)
  127. [2]=>
  128. int(%d)
  129. [3]=>
  130. int(%d)
  131. [4]=>
  132. int(%d)
  133. [5]=>
  134. int(%d)
  135. [6]=>
  136. int(%d)
  137. [7]=>
  138. int(%d)
  139. [8]=>
  140. int(%d)
  141. [9]=>
  142. int(%d)
  143. [10]=>
  144. int(%d)
  145. [11]=>
  146. int(-1)
  147. [12]=>
  148. int(-1)
  149. ["dev"]=>
  150. int(%d)
  151. ["ino"]=>
  152. int(%d)
  153. ["mode"]=>
  154. int(%d)
  155. ["nlink"]=>
  156. int(%d)
  157. ["uid"]=>
  158. int(%d)
  159. ["gid"]=>
  160. int(%d)
  161. ["rdev"]=>
  162. int(%d)
  163. ["size"]=>
  164. int(%d)
  165. ["atime"]=>
  166. int(%d)
  167. ["mtime"]=>
  168. int(%d)
  169. ["ctime"]=>
  170. int(%d)
  171. ["blksize"]=>
  172. int(-1)
  173. ["blocks"]=>
  174. int(-1)
  175. }
  176. bool(true)
  177. *** Testing stat(): for the return value ***
  178. bool(true)
  179. ---Done---