diff options
Diffstat (limited to 'ext/standard/tests/file/tempnam_variation7-win32.phpt')
-rw-r--r-- | ext/standard/tests/file/tempnam_variation7-win32.phpt | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/ext/standard/tests/file/tempnam_variation7-win32.phpt b/ext/standard/tests/file/tempnam_variation7-win32.phpt index 9ad75f8ed5..5beaa6d095 100644 --- a/ext/standard/tests/file/tempnam_variation7-win32.phpt +++ b/ext/standard/tests/file/tempnam_variation7-win32.phpt @@ -9,57 +9,58 @@ if(substr(PHP_OS, 0, 3) != "WIN") obscure_filename --FILE-- <?php -/* Prototype: string tempnam ( string $dir, string $prefix ); - Description: Create file with unique file name. -*/ - /* Passing invalid/non-existing args for $dir, hence the unique files will be created in temporary dir */ echo "*** Testing tempnam() with invalid/non-existing directory names ***\n"; /* An array of names, which will be passed as a dir name */ $names_arr = array( - /* Invalid args */ - -1, - TRUE, - FALSE, - NULL, - "", - " ", - "\0", - array(), - - /* Non-existing dirs */ - "/no/such/file/dir", - "php" + /* Invalid args */ + -1, + TRUE, + FALSE, + NULL, + "", + " ", + "\0", + array(), + + /* Non-existing dirs */ + "/no/such/file/dir", + "php" ); for( $i=0; $i<count($names_arr); $i++ ) { - echo "-- Iteration $i --\n"; - $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp"); - - if( file_exists($file_name) ){ - - echo "File name is => "; - print($file_name); - echo "\n"; - - echo "File permissions are => "; - printf("%o", fileperms($file_name) ); - echo "\n"; - - echo "File created in => "; - $file_dir = dirname($file_name); - if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) { - echo "temp dir\n"; - } else { - echo "unknown location\n"; - } - } else { - echo "-- File is not created --\n"; - } - - unlink($file_name); + echo "-- Iteration $i --\n"; + try { + $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp"); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + continue; + } + + if( file_exists($file_name) ){ + + echo "File name is => "; + print($file_name); + echo "\n"; + + echo "File permissions are => "; + printf("%o", fileperms($file_name) ); + echo "\n"; + + echo "File created in => "; + $file_dir = dirname($file_name); + if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) { + echo "temp dir\n"; + } else { + echo "unknown location\n"; + } + } else { + echo "-- File is not created --\n"; + } + + unlink($file_name); } ?> --EXPECTF-- @@ -95,17 +96,9 @@ File name is => %s%et%s File permissions are => 100666 File created in => temp dir -- Iteration 6 -- - -Warning: tempnam() expects parameter 1 to be a valid path, string given in %stempnam_variation7-win32.php on line %d --- File is not created -- - -Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d +tempnam(): Argument #1 ($dir) must be a valid path, string given -- Iteration 7 -- - -Warning: tempnam() expects parameter 1 to be a valid path, array given in %s on line %d --- File is not created -- - -Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d +tempnam(): Argument #1 ($dir) must be a valid path, array given -- Iteration 8 -- Notice: tempnam(): file created in the system's temporary directory in %stempnam_variation7-win32.php on line %d |