Annotation of embedaddon/php/ext/standard/tests/file/tempnam_variation7-win32.phpt, revision 1.1.1.1
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 */
16:
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 --
92: -- File is not created --
93:
94: Warning: unlink(): %s in %s on line %d
95: -- Iteration 7 --
96:
97: Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
98: -- File is not created --
99:
100: Warning: unlink(): %s in %s on line %d
101: -- Iteration 8 --
102: File name is => %s%et%s
103: File permissions are => 100666
104: File created in => temp dir
105: -- Iteration 9 --
106: File name is => %s%et%s
107: File permissions are => 100666
108: File created in => temp dir
109:
110: *** Done ***
111:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>