Annotation of embedaddon/php/ext/standard/tests/file/mkdir_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mkdir() function : usage variation: try invalid pathname
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 Not valid for Windows");
9: ?>
10: --FILE--
11: <?php
12: /* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
13: * Description: Create a directory
14: * Source code: ext/standard/file.c
15: * Alias to functions:
16: */
17:
18: echo "*** Testing mkdir() : usage variation ***\n";
19:
20: // Define error handler
21: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
22: if (error_reporting() != 0) {
23: // report non-silenced errors
24: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
25: }
26: }
27: set_error_handler('test_error_handler');
28:
29: //get an unset variable
30: $unset_var = 10;
31: unset ($unset_var);
32:
33: // define some classes
34: class classWithToString
35: {
36: public function __toString() {
37: return "Class A object";
38: }
39: }
40:
41: class classWithoutToString
42: {
43: }
44:
45: // heredoc string
46: $heredoc = <<<EOT
47: hello world
48: EOT;
49:
50: // add arrays
51: $index_array = array (1, 2, 3);
52: $assoc_array = array ('one' => 1, 'two' => 2);
53:
54: //array of values to iterate over
55: $inputs = array(
56:
57: // null data
58: 'uppercase NULL' => NULL,
59: 'lowercase null' => null,
60:
61: // boolean data
62: 'lowercase false' =>false,
63: 'uppercase FALSE' =>FALSE,
64:
65: // empty data
66: 'empty string DQ' => "",
67: 'empty string SQ' => '',
68:
69: // undefined data
70: 'undefined var' => @$undefined_var,
71:
72: // unset data
73: 'unset var' => @$unset_var,
74:
75: // other
76: 'single space' => ' ',
77: );
78:
79: // loop through each element of the array for pathname
80:
81: foreach($inputs as $key =>$value) {
82: echo "\n--$key--\n";
83: $res = mkdir($value);
84: if ($res == true) {
85: echo "directory created\n";
86: rmdir($value);
87: }
88: };
89:
90: ?>
91: ===DONE===
92: --EXPECTF--
93: *** Testing mkdir() : usage variation ***
94:
95: --uppercase NULL--
96: Error: 2 - mkdir(): %s, %s(%d)
97:
98: --lowercase null--
99: Error: 2 - mkdir(): %s, %s(%d)
100:
101: --lowercase false--
102: Error: 2 - mkdir(): %s, %s(%d)
103:
104: --uppercase FALSE--
105: Error: 2 - mkdir(): %s, %s(%d)
106:
107: --empty string DQ--
108: Error: 2 - mkdir(): %s, %s(%d)
109:
110: --empty string SQ--
111: Error: 2 - mkdir(): %s, %s(%d)
112:
113: --undefined var--
114: Error: 2 - mkdir(): %s, %s(%d)
115:
116: --unset var--
117: Error: 2 - mkdir(): %s, %s(%d)
118:
119: --single space--
120: directory created
121: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>