Annotation of embedaddon/php/ext/standard/tests/strings/join_variation2.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test join() function : usage variations - unexpected values for 'pieces' argument(Bug#42789)
3: --FILE--
4: <?php
5: /* Prototype : string join( string $glue, array $pieces )
6: * Description: Join array elements with a string
7: * Source code: ext/standard/string.c
8: * Alias of function: implode()
9: */
10:
11: /*
12: * test join() by passing different unexpected value for pieces argument
13: */
14:
15: echo "*** Testing join() : usage variations ***\n";
16: // initialize all required variables
17: $glue = '::';
18:
19: // get an unset variable
20: $unset_var = array(1, 2);
21: unset($unset_var);
22:
23: // get a resouce variable
24: $fp = fopen(__FILE__, "r");
25:
26: // define a class
27: class test
28: {
29: var $t = 10;
30: var $p = 10;
31: function __toString() {
32: return "testObject";
33: }
34: }
35:
36: // array with different values
37: $values = array (
38:
39: // integer values
40: 0,
41: 1,
42: 12345,
43: -2345,
44:
45: // float values
46: 10.5,
47: -10.5,
48: 10.5e10,
49: 10.6E-10,
50: .5,
51:
52: // boolean values
53: true,
54: false,
55: TRUE,
56: FALSE,
57:
58: // string values
59: "string",
60: 'string',
61:
62: // objects
63: new test(),
64:
65: // empty string
66: "",
67: '',
68:
69: // null vlaues
70: NULL,
71: null,
72:
73: // resource variable
74: $fp,
75:
76: // undefined variable
77: @$undefined_var,
78:
79: // unset variable
80: @$unset_var
81: );
82:
83:
84: // loop through each element of the array and check the working of join()
1.1.1.2 ! misho 85: // when $pieces argument is supplied with different values
1.1 misho 86: echo "\n--- Testing join() by supplying different values for 'pieces' argument ---\n";
87: $counter = 1;
88: for($index = 0; $index < count($values); $index ++) {
89: echo "-- Iteration $counter --\n";
90: $pieces = $values [$index];
91:
92: var_dump( join($glue, $pieces) );
93:
94: $counter ++;
95: }
96:
97: // close the resources used
98: fclose($fp);
99:
100: echo "Done\n";
101: ?>
102: --EXPECTF--
103: *** Testing join() : usage variations ***
104:
105: --- Testing join() by supplying different values for 'pieces' argument ---
106: -- Iteration 1 --
107:
108: Warning: join(): Invalid arguments passed in %s on line %d
109: NULL
110: -- Iteration 2 --
111:
112: Warning: join(): Invalid arguments passed in %s on line %d
113: NULL
114: -- Iteration 3 --
115:
116: Warning: join(): Invalid arguments passed in %s on line %d
117: NULL
118: -- Iteration 4 --
119:
120: Warning: join(): Invalid arguments passed in %s on line %d
121: NULL
122: -- Iteration 5 --
123:
124: Warning: join(): Invalid arguments passed in %s on line %d
125: NULL
126: -- Iteration 6 --
127:
128: Warning: join(): Invalid arguments passed in %s on line %d
129: NULL
130: -- Iteration 7 --
131:
132: Warning: join(): Invalid arguments passed in %s on line %d
133: NULL
134: -- Iteration 8 --
135:
136: Warning: join(): Invalid arguments passed in %s on line %d
137: NULL
138: -- Iteration 9 --
139:
140: Warning: join(): Invalid arguments passed in %s on line %d
141: NULL
142: -- Iteration 10 --
143:
144: Warning: join(): Invalid arguments passed in %s on line %d
145: NULL
146: -- Iteration 11 --
147:
148: Warning: join(): Invalid arguments passed in %s on line %d
149: NULL
150: -- Iteration 12 --
151:
152: Warning: join(): Invalid arguments passed in %s on line %d
153: NULL
154: -- Iteration 13 --
155:
156: Warning: join(): Invalid arguments passed in %s on line %d
157: NULL
158: -- Iteration 14 --
159:
160: Warning: join(): Invalid arguments passed in %s on line %d
161: NULL
162: -- Iteration 15 --
163:
164: Warning: join(): Invalid arguments passed in %s on line %d
165: NULL
166: -- Iteration 16 --
167:
168: Warning: join(): Invalid arguments passed in %s on line %d
169: NULL
170: -- Iteration 17 --
171:
172: Warning: join(): Invalid arguments passed in %s on line %d
173: NULL
174: -- Iteration 18 --
175:
176: Warning: join(): Invalid arguments passed in %s on line %d
177: NULL
178: -- Iteration 19 --
179:
180: Warning: join(): Invalid arguments passed in %s on line %d
181: NULL
182: -- Iteration 20 --
183:
184: Warning: join(): Invalid arguments passed in %s on line %d
185: NULL
186: -- Iteration 21 --
187:
188: Warning: join(): Invalid arguments passed in %s on line %d
189: NULL
190: -- Iteration 22 --
191:
192: Warning: join(): Invalid arguments passed in %s on line %d
193: NULL
194: -- Iteration 23 --
195:
196: Warning: join(): Invalid arguments passed in %s on line %d
197: NULL
198: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>