Return to is_file_variation1.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test is_file() function: usage variations - diff. files 3: --FILE-- 4: <?php 5: /* Prototype: bool is_file ( string $filename ); 6: Description: Tells whether the filename is a regular file 7: Returns TRUE if the filename exists and is a regular file 8: */ 9: 10: /* Testing is_file() with file containing data, truncating its size 11: and the file created by touch() */ 12: 13: $file_path = dirname(__FILE__); 14: 15: echo "-- Testing is_file() with file containing data --\n"; 16: $filename = $file_path."/is_file_variation1.tmp"; 17: $file_handle = fopen($filename, "w" ); 18: fwrite( $file_handle, "Hello, world....." ); // exptected true 19: fclose($file_handle); 20: var_dump( is_file($filename) ); 21: clearstatcache(); 22: 23: echo "\n-- Testing is_file() after truncating filesize to zero bytes --\n"; 24: $file_handle = fopen( $file_path."/is_file_variation1.tmp", "r"); 25: ftruncate($file_handle, 0); 26: fclose($file_handle); 27: var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true 28: clearstatcache(); 29: unlink($file_path."/is_file_variation1.tmp"); 30: 31: echo "\n-- Testing is_file() with an empty file --\n"; 32: /* created by fopen() */ 33: fclose( fopen($file_path."/is_file_variation1.tmp", "w") ); 34: var_dump( is_file($file_path."/is_file_variation1.tmp") ); //expected true 35: clearstatcache(); 36: unlink($file_path."/is_file_variation1.tmp"); 37: 38: /* created by touch() */ 39: touch($file_path."/is_file_variation1.tmp"); 40: var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true 41: clearstatcache(); 42: unlink($file_path."/is_file_variation1.tmp"); 43: 44: echo "\n*** Done ***"; 45: ?> 46: --EXPECTF-- 47: -- Testing is_file() with file containing data -- 48: bool(true) 49: 50: -- Testing is_file() after truncating filesize to zero bytes -- 51: bool(true) 52: 53: -- Testing is_file() with an empty file -- 54: bool(true) 55: bool(true) 56: 57: *** Done ***