Annotation of embedaddon/php/ext/standard/tests/file/stat_basic-win32.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>