Annotation of embedaddon/php/ext/standard/tests/file/mkdir_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mkdir() function : usage variation: different types for mode
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --FILE--
6: <?php
7: /* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
8: * Description: Create a directory
9: * Source code: ext/standard/file.c
10: * Alias to functions:
11: */
12:
13: echo "*** Testing mkdir() : usage variation ***\n";
14:
15: // Define error handler
16: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
17: if (error_reporting() != 0) {
18: // report non-silenced errors
19: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
20: }
21: }
22: set_error_handler('test_error_handler');
23:
24: // Initialise function arguments not being substituted (if any)
25: $pathname = 'mkdirVar2.tmp';
26:
27: //get an unset variable
28: $unset_var = 10;
29: unset ($unset_var);
30:
31: // define some classes
32: class classWithToString
33: {
34: public function __toString() {
35: return "Class A object";
36: }
37: }
38:
39: class classWithoutToString
40: {
41: }
42:
43: // heredoc string
44: $heredoc = <<<EOT
45: hello world
46: EOT;
47:
48: // add arrays
49: $index_array = array (1, 2, 3);
50: $assoc_array = array ('one' => 1, 'two' => 2);
51:
52: //array of values to iterate over
53: $inputs = array(
54:
55: // float data
56: 'float 10.5' => 10.5,
57: 'float -10.5' => -10.5,
58: 'float 12.3456789000e10' => 12.3456789000e10,
59: 'float -12.3456789000e10' => -12.3456789000e10,
60: 'float .5' => .5,
61:
62: // array data
63: 'empty array' => array(),
64: 'int indexed array' => $index_array,
65: 'associative array' => $assoc_array,
66: 'nested arrays' => array('foo', $index_array, $assoc_array),
67:
68: // null data
69: 'uppercase NULL' => NULL,
70: 'lowercase null' => null,
71:
72: // boolean data
73: 'lowercase true' => true,
74: 'lowercase false' =>false,
75: 'uppercase TRUE' =>TRUE,
76: 'uppercase FALSE' =>FALSE,
77:
78: // empty data
79: 'empty string DQ' => "",
80: 'empty string SQ' => '',
81:
82: // string data
83: 'string DQ' => "string",
84: 'string SQ' => 'string',
85: 'mixed case string' => "sTrInG",
86: 'heredoc' => $heredoc,
87:
88: // object data
89: 'instance of classWithToString' => new classWithToString(),
90: 'instance of classWithoutToString' => new classWithoutToString(),
91:
92: // undefined data
93: 'undefined var' => @$undefined_var,
94:
95: // unset data
96: 'unset var' => @$unset_var,
97: );
98:
99: // loop through each element of the array for mode
100:
101: foreach($inputs as $key =>$value) {
102: echo "\n--$key--\n";
103: $h = mkdir($pathname, $value);
104: if ($h === true) {
105: echo "Directory created\n";
106: rmdir($pathname);
107: }
108: };
109:
110: ?>
111: ===DONE===
112: --EXPECTF--
113: *** Testing mkdir() : usage variation ***
114:
115: --float 10.5--
116: Directory created
117:
118: --float -10.5--
119: Directory created
120:
121: --float 12.3456789000e10--
122: Directory created
123:
124: --float -12.3456789000e10--
125: Directory created
126:
127: --float .5--
128: Directory created
129:
130: --empty array--
131: Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
132:
133: --int indexed array--
134: Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
135:
136: --associative array--
137: Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
138:
139: --nested arrays--
140: Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
141:
142: --uppercase NULL--
143: Directory created
144:
145: --lowercase null--
146: Directory created
147:
148: --lowercase true--
149: Directory created
150:
151: --lowercase false--
152: Directory created
153:
154: --uppercase TRUE--
155: Directory created
156:
157: --uppercase FALSE--
158: Directory created
159:
160: --empty string DQ--
161: Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
162:
163: --empty string SQ--
164: Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
165:
166: --string DQ--
167: Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
168:
169: --string SQ--
170: Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
171:
172: --mixed case string--
173: Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
174:
175: --heredoc--
176: Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
177:
178: --instance of classWithToString--
179: Error: 2 - mkdir() expects parameter 2 to be long, object given, %s(%d)
180:
181: --instance of classWithoutToString--
182: Error: 2 - mkdir() expects parameter 2 to be long, object given, %s(%d)
183:
184: --undefined var--
185: Directory created
186:
187: --unset var--
188: Directory created
189: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>