Return to tempnam_variation7-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test tempnam() function: usage variations - invalid/non-existing dir 3: --SKIPIF-- 4: <?php 5: if(substr(PHP_OS, 0, 3) != "WIN") 6: die("skip Only run on Windows"); 7: ?> 8: --FILE-- 9: <?php 10: /* Prototype: string tempnam ( string $dir, string $prefix ); 11: Description: Create file with unique file name. 12: */ 13: 14: /* Passing invalid/non-existing args for $dir, 15: hence the unique files will be created in temporary dir */ 1.1.1.2 misho 16: 1.1 misho 17: echo "*** Testing tempnam() with invalid/non-existing directory names ***\n"; 18: /* An array of names, which will be passed as a dir name */ 19: $names_arr = array( 20: /* Invalid args */ 21: -1, 22: TRUE, 23: FALSE, 24: NULL, 25: "", 26: " ", 27: "\0", 28: array(), 29: 30: /* Non-existing dirs */ 31: "/no/such/file/dir", 32: "php" 33: ); 34: 35: for( $i=0; $i<count($names_arr); $i++ ) { 36: echo "-- Iteration $i --\n"; 37: $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp"); 38: 39: if( file_exists($file_name) ){ 40: 41: echo "File name is => "; 42: print($file_name); 43: echo "\n"; 44: 45: echo "File permissions are => "; 46: printf("%o", fileperms($file_name) ); 47: echo "\n"; 48: 49: echo "File created in => "; 50: $file_dir = dirname($file_name); 51: if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) { 52: echo "temp dir\n"; 53: } else { 54: echo "unknown location\n"; 55: } 56: } else { 57: echo "-- File is not created --\n"; 58: } 59: 60: unlink($file_name); 61: } 62: 63: echo "\n*** Done ***\n"; 64: ?> 65: --EXPECTF-- 66: *** Testing tempnam() with invalid/non-existing directory names *** 67: -- Iteration 0 -- 68: File name is => %s%et%s 69: File permissions are => 100666 70: File created in => temp dir 71: -- Iteration 1 -- 72: File name is => %s%et%s 73: File permissions are => 100666 74: File created in => temp dir 75: -- Iteration 2 -- 76: File name is => %s%et%s 77: File permissions are => 100666 78: File created in => temp dir 79: -- Iteration 3 -- 80: File name is => %s%et%s 81: File permissions are => 100666 82: File created in => temp dir 83: -- Iteration 4 -- 84: File name is => %s%et%s 85: File permissions are => 100666 86: File created in => temp dir 87: -- Iteration 5 -- 88: File name is => %s%et%s 89: File permissions are => 100666 90: File created in => temp dir 91: -- Iteration 6 -- 1.1.1.2 misho 92: 93: Warning: tempnam() expects parameter 1 to be a valid path, string given in %stempnam_variation7-win32.php on line %d 1.1 misho 94: -- File is not created -- 95: 1.1.1.3 ! misho 96: Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d 1.1 misho 97: -- Iteration 7 -- 98: 1.1.1.2 misho 99: Warning: tempnam() expects parameter 1 to be a valid path, array given in %s on line %d 1.1 misho 100: -- File is not created -- 101: 1.1.1.3 ! misho 102: Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d 1.1 misho 103: -- Iteration 8 -- 104: File name is => %s%et%s 105: File permissions are => 100666 106: File created in => temp dir 107: -- Iteration 9 -- 108: File name is => %s%et%s 109: File permissions are => 100666 110: File created in => temp dir 111: 112: *** Done *** 113: