diff options
Diffstat (limited to 'ext/standard/tests/file/tempnam_variation7.phpt')
-rw-r--r-- | ext/standard/tests/file/tempnam_variation7.phpt | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/ext/standard/tests/file/tempnam_variation7.phpt b/ext/standard/tests/file/tempnam_variation7.phpt index ebecd1601f..0e314dabe3 100644 --- a/ext/standard/tests/file/tempnam_variation7.phpt +++ b/ext/standard/tests/file/tempnam_variation7.phpt @@ -3,7 +3,7 @@ Test tempnam() function: usage variations - invalid/non-existing dir --SKIPIF-- <?php if(substr(PHP_OS, 0, 3) == "WIN") - die("skip DO not run on Windows"); + die("skip Do not run on Windows"); ?> --FILE-- <?php @@ -15,8 +15,6 @@ if(substr(PHP_OS, 0, 3) == "WIN") hence the unique files will be created in temporary dir */ echo "*** Testing tempnam() with invalid/non-existing directory names ***\n"; -$file_path = dirname(__FILE__); - /* An array of names, which will be passed as a dir name */ $names_arr = array( /* Invalid args */ @@ -26,7 +24,7 @@ $names_arr = array( NULL, "", " ", - "/0", + "\0", array(), /* Non-existing dirs */ @@ -35,7 +33,7 @@ $names_arr = array( ); -for( $i=1; $i<count($names_arr); $i++ ) { +for( $i=0; $i<count($names_arr); $i++ ) { echo "-- Iteration $i --\n"; $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp"); @@ -48,9 +46,21 @@ for( $i=1; $i<count($names_arr); $i++ ) { 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())) { + echo "temp dir\n"; + } + else { + echo "unknown location\n"; + } + } - else + else { echo "-- File is not created --\n"; + } unlink($file_name); } @@ -59,24 +69,34 @@ echo "\n*** Done ***\n"; ?> --EXPECTF-- *** Testing tempnam() with invalid/non-existing directory names *** +-- Iteration 0 -- +File name is => %s%etempnam_variation3.tmp%s +File permissions are => 100600 +File created in => temp dir -- Iteration 1 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir -- Iteration 2 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir -- Iteration 3 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir -- Iteration 4 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir -- Iteration 5 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir -- Iteration 6 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir -- Iteration 7 -- Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d @@ -84,10 +104,13 @@ Warning: tempnam() expects parameter 1 to be string, array given in %s on line % Warning: unlink(): No such file or directory in %s on line %d -- Iteration 8 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir -- Iteration 9 -- -File name is => %s +File name is => %s%etempnam_variation3.tmp%s File permissions are => 100600 +File created in => temp dir *** Done *** + |