Annotation of embedaddon/php/ext/standard/tests/file/filesize_variation2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test filesize() function: usage variations - size of dir/subdir
                      3: --SKIPIF--
                      4: <?php
                      5: if (substr(PHP_OS, 0, 3) == 'WIN') {
                      6:     die('skip only valid for Linux');
                      7: }
                      8: --FILE--
                      9: <?php
                     10: /* 
                     11:  Prototype   : int filesize ( string $filename );
                     12:  Description : Returns the size of the file in bytes, or FALSE 
                     13:    (and generates an error of level E_WARNING) in case of an error.
                     14: */
                     15: 
                     16: $file_path = dirname(__FILE__);
                     17: require($file_path."/file.inc");
                     18: 
                     19: echo "*** Testing filesize(): usage variations ***\n"; 
                     20: 
                     21: echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n";
                     22: echo "-- Creating a base dir, and checking its size --\n";
                     23: mkdir( $file_path."/filesize_variation2");
                     24: var_dump( filesize( $file_path."/filesize_variation2"));
                     25: clearstatcache();
                     26: 
                     27: echo "-- Creating a file inside base dir, and checking dir & file size --\n"; 
                     28: create_files($file_path."/filesize_variation2", 1, "numeric", 0755, 1, "w", "filesize_variation");
                     29: var_dump( filesize( $file_path."/filesize_variation2"));
                     30: clearstatcache();
                     31: var_dump( filesize( $file_path."/filesize_variation2/filesize_variation1.tmp"));
                     32: clearstatcache();
                     33: delete_files($file_path."/filesize_variation2", 1, "filesize_variation");
                     34: 
                     35: echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n";
                     36: mkdir( $file_path."/filesize_variation2/filesize_variation2_sub");
                     37: var_dump( filesize( $file_path."/filesize_variation2")); // size of base dir
                     38: clearstatcache();
                     39: var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub")); // size of subdir
                     40: clearstatcache();
                     41: 
                     42: echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n";
                     43: // create only the file, as base and subdir is already created
                     44: $filename =  $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp";
                     45: $file_handle = fopen($filename, "w");
                     46: fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
                     47: fclose($file_handle);
                     48: // size of base dir
                     49: var_dump( filesize( $file_path."/filesize_variation2"));
                     50: clearstatcache();
                     51: // size of subdir
                     52: var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub"));
                     53: clearstatcache();
                     54: // size of file inside subdir
                     55: var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp"));
                     56: clearstatcache();
                     57: 
                     58: echo "*** Done ***\n";
                     59: ?>
                     60: --CLEAN--
                     61: <?php
                     62: $file_path = dirname(__FILE__);
                     63: unlink($file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp");
                     64: rmdir($file_path."/filesize_variation2/filesize_variation2_sub");
                     65: rmdir($file_path."/filesize_variation2");
                     66: ?>
                     67: --EXPECTF--
                     68: *** Testing filesize(): usage variations ***
                     69: 
                     70: *** Testing size of a dir, sub-dir and file with filesize() ***
                     71: -- Creating a base dir, and checking its size --
                     72: int(%d)
                     73: -- Creating a file inside base dir, and checking dir & file size --
                     74: int(%d)
                     75: int(1024)
                     76: -- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --
                     77: int(%d)
                     78: int(%d)
                     79: -- Creating a file inside sub-dir, and checking size of base, subdir and file created --
                     80: int(%d)
                     81: int(%d)
                     82: int(12000)
                     83: *** Done ***

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