Annotation of embedaddon/php/ext/standard/tests/file/tempnam_variation8-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test tempnam() function: usage variations - various absolute and relative paths
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --SKIPIF--
6: <?php
7: if(substr(PHP_OS, 0, 3) != "WIN")
8: die("skip Only valid for Windows");
9: ?>
10: --FILE--
11: <?php
12: /* Prototype: string tempnam ( string $dir, string $prefix );
13: Description: Create file with unique file name.
14: */
15:
16: /* Creating unique files in various dirs by passing relative paths to $dir arg */
17:
18: echo "*** Testing tempnam() with absolute and relative paths ***\n";
19: $dir_name = dirname(__FILE__)."\\tempnam_variation2";
20: mkdir($dir_name);
21: $dir_path = $dir_name."/tempnam_variation2_sub";
22: mkdir($dir_path);
23:
24: $old_dir_path = getcwd();
25: chdir(dirname(__FILE__));
26:
27: $dir_paths = array(
28: // absolute paths
29: "$dir_path\\",
30: "$dir_path\\..",
31: "$dir_path\\\\..\\",
32: "$dir_path\\..\\..\\.\\tempnam_variation2",
33: "$dir_path\\..\\\\\\tempnam_variation2_sub\\\\..\\\\..\\tempnam_variation2",
34: "$dir_path\\BADDIR",
35:
36:
37: // relative paths
38: "tempname_variation2\\",
39: "tempnam_variation2\\tempnam_variation2_sub",
40: "tempnam_variation2\\\\tempnam_variation2_sub",
41: ".\\tempnam_variation2\\..\\tempnam_variation2\\tempnam_variation2_sub",
42: "BADDIR",
43: );
44:
45: for($i = 0; $i<count($dir_paths); $i++) {
46: $j = $i+1;
47: echo "\n-- Iteration $j --\n";
48: $file_name = tempnam($dir_paths[$i], "tempnam_variation2.tmp");
49:
50: if( file_exists($file_name) ){
51:
52: echo "File name is => ";
53: print(realpath($file_name));
54: echo "\n";
55:
56: echo "File permissions are => ";
57: printf("%o", fileperms($file_name) );
58: echo "\n";
59:
60: echo "File created in => ";
61: $file_dir = dirname($file_name);
62: $dir_req = $dir_paths[$i];
63:
64: if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
65: echo "temp dir\n";
66: }
67: else if (realpath($file_dir) == realpath($dir_req) || realpath($file_dir."\\") == realpath($dir_req)) {
68: echo "directory specified\n";
69: }
70: else {
71: echo "unknown location\n";
72: }
73:
74:
75: }
76: else {
77: echo "-- File is not created --";
78: }
79:
80: unlink($file_name);
81: }
82:
83: chdir($old_dir_path);
84: rmdir($dir_path);
85: rmdir($dir_name);
86:
87: echo "\n*** Done ***\n";
88: ?>
89: --EXPECTF--
90: *** Testing tempnam() with absolute and relative paths ***
91:
92: -- Iteration 1 --
93: File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
94: File permissions are => 100666
95: File created in => directory specified
96:
97: -- Iteration 2 --
98: File name is => %s\tempnam_variation2\t%s
99: File permissions are => 100666
100: File created in => directory specified
101:
102: -- Iteration 3 --
103: File name is => %s\tempnam_variation2\t%s
104: File permissions are => 100666
105: File created in => directory specified
106:
107: -- Iteration 4 --
108: File name is => %s\tempnam_variation2\t%s
109: File permissions are => 100666
110: File created in => directory specified
111:
112: -- Iteration 5 --
113: File name is => %s\tempnam_variation2\t%s
114: File permissions are => 100666
115: File created in => directory specified
116:
117: -- Iteration 6 --
118: File name is => %s\t%s
119: File permissions are => 100666
120: File created in => temp dir
121:
122: -- Iteration 7 --
123: File name is => %s\t%s
124: File permissions are => 100666
125: File created in => temp dir
126:
127: -- Iteration 8 --
128: File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
129: File permissions are => 100666
130: File created in => directory specified
131:
132: -- Iteration 9 --
133: File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
134: File permissions are => 100666
135: File created in => directory specified
136:
137: -- Iteration 10 --
138: File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
139: File permissions are => 100666
140: File created in => directory specified
141:
142: -- Iteration 11 --
143: File name is => %s\t%s
144: File permissions are => 100666
145: File created in => temp dir
146:
147: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>