Skip to content

Commit 9d56ec9

Browse files
committed
Add tests for nesting dimensions
1 parent 88fc23f commit 9d56ec9

8 files changed

+812
-26
lines changed

Zend/tests/offsets/array_container_offset_behaviour.phpt

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ bool(false)
2121
null coalesce:
2222
int(25)
2323
unset():
24+
Nested read:
2425
26+
Warning: Undefined array key %s in %s on line 62
27+
28+
Warning: Trying to access array offset on null in %s on line 62
29+
NULL
30+
Nested write:
31+
Nested Read-Write:
32+
Nested isset():
33+
bool(true)
34+
Nested empty():
35+
bool(false)
36+
Nested null coalesce:
37+
int(30)
38+
Nested unset():
2539
OUTPUT;
2640

2741
$EXPECTED_OUTPUT_VALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_VALID_OFFSETS) . '$/s';
@@ -58,6 +72,47 @@ int(35)
5872
unset():
5973
6074
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 55
75+
Nested read:
76+
77+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 62
78+
79+
Warning: Undefined array key 0 in %s on line 62
80+
81+
Warning: Trying to access array offset on null in %s on line 62
82+
NULL
83+
Nested write:
84+
85+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69
86+
87+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69
88+
Nested Read-Write:
89+
90+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76
91+
92+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76
93+
Nested isset():
94+
95+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83
96+
97+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83
98+
bool(true)
99+
Nested empty():
100+
101+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89
102+
103+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89
104+
bool(false)
105+
Nested null coalesce:
106+
107+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95
108+
109+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95
110+
int(25)
111+
Nested unset():
112+
113+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102
114+
115+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102
61116
62117
OUTPUT;
63118

@@ -80,6 +135,20 @@ null coalesce:
80135
Cannot access offset of type %s on array
81136
unset():
82137
Cannot unset offset of type %s on array
138+
Nested read:
139+
Cannot access offset of type %s on array
140+
Nested write:
141+
Cannot access offset of type %s on array
142+
Nested Read-Write:
143+
Cannot access offset of type %s on array
144+
Nested isset():
145+
Cannot access offset of type %s on array
146+
Nested empty():
147+
Cannot access offset of type %s on array
148+
Nested null coalesce:
149+
Cannot access offset of type %s on array
150+
Nested unset():
151+
Cannot access offset of type %s on array
83152
84153
OUTPUT;
85154

@@ -117,6 +186,47 @@ int(25)
117186
unset():
118187
119188
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 55
189+
Nested read:
190+
191+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 62
192+
193+
Warning: Undefined array key 3 in %s on line 62
194+
195+
Warning: Trying to access array offset on null in %s on line 62
196+
NULL
197+
Nested write:
198+
199+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69
200+
201+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69
202+
Nested Read-Write:
203+
204+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76
205+
206+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76
207+
Nested isset():
208+
209+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83
210+
211+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83
212+
bool(true)
213+
Nested empty():
214+
215+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89
216+
217+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89
218+
bool(false)
219+
Nested null coalesce:
220+
221+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95
222+
223+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95
224+
int(30)
225+
Nested unset():
226+
227+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102
228+
229+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102
120230
121231
OUTPUT;
122232

Zend/tests/offsets/false_container_offset_behaviour.phpt

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,34 @@ bool(false)
2323
null coalesce:
2424
int(25)
2525
unset():
26+
Nested read:
27+
28+
Warning: Undefined array key %s in %s on line 62
29+
30+
Warning: Trying to access array offset on null in %s on line 62
31+
NULL
32+
Nested write:
33+
Nested Read-Write:
34+
Nested isset():
35+
bool(true)
36+
Nested empty():
37+
bool(false)
38+
Nested null coalesce:
39+
int(30)
40+
Nested unset():
2641
2742
OUTPUT;
2843

44+
$EXPECTED_OUTPUT_VALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_VALID_OFFSETS) . '$/s';
45+
2946
const EXPECTF_OUTPUT_FLOAT_OFFSETS = <<<OUTPUT
3047
Read before write:
3148
3249
Warning: Trying to access array offset on false in %s on line 8
3350
NULL
3451
Write:
3552
36-
Deprecated: Automatic conversion of false to array is deprecated %s on line 15
53+
Deprecated: Automatic conversion of false to array is deprecated in %s on line 15
3754
3855
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 15
3956
Read:
@@ -58,6 +75,47 @@ int(25)
5875
unset():
5976
6077
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 55
78+
Nested read:
79+
80+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 62
81+
82+
Warning: Undefined array key 0 in %s on line 62
83+
84+
Warning: Trying to access array offset on null in %s on line 62
85+
NULL
86+
Nested write:
87+
88+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69
89+
90+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69
91+
Nested Read-Write:
92+
93+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76
94+
95+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76
96+
Nested isset():
97+
98+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83
99+
100+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83
101+
bool(true)
102+
Nested empty():
103+
104+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89
105+
106+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89
107+
bool(false)
108+
Nested null coalesce:
109+
110+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95
111+
112+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95
113+
int(30)
114+
Nested unset():
115+
116+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102
117+
118+
Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102
61119
62120
OUTPUT;
63121

@@ -70,7 +128,7 @@ Warning: Trying to access array offset on false in %s on line 8
70128
NULL
71129
Write:
72130
73-
Deprecated: Automatic conversion of false to array is deprecated %s on line 15
131+
Deprecated: Automatic conversion of false to array is deprecated in %s on line 15
74132
Cannot access offset of type %s on array
75133
Read:
76134
Cannot access offset of type %s on array
@@ -84,6 +142,20 @@ null coalesce:
84142
Cannot access offset of type %s on array
85143
unset():
86144
Cannot unset offset of type %s on array
145+
Nested read:
146+
Cannot access offset of type %s on array
147+
Nested write:
148+
Cannot access offset of type %s on array
149+
Nested Read-Write:
150+
Cannot access offset of type %s on array
151+
Nested isset():
152+
Cannot access offset of type %s on array
153+
Nested empty():
154+
Cannot access offset of type %s on array
155+
Nested null coalesce:
156+
Cannot access offset of type %s on array
157+
Nested unset():
158+
Cannot access offset of type %s on array
87159
88160
OUTPUT;
89161

@@ -121,6 +193,47 @@ int(25)
121193
unset():
122194
123195
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 55
196+
Nested read:
197+
198+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 62
199+
200+
Warning: Undefined array key 3 in %s on line 62
201+
202+
Warning: Trying to access array offset on null in %s on line 62
203+
NULL
204+
Nested write:
205+
206+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69
207+
208+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69
209+
Nested Read-Write:
210+
211+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76
212+
213+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76
214+
Nested isset():
215+
216+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83
217+
218+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83
219+
bool(true)
220+
Nested empty():
221+
222+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89
223+
224+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89
225+
bool(false)
226+
Nested null coalesce:
227+
228+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95
229+
230+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95
231+
int(30)
232+
Nested unset():
233+
234+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102
235+
236+
Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102
124237
125238
OUTPUT;
126239

@@ -139,7 +252,7 @@ foreach ($offsets as $dimension) {
139252
);
140253

141254
if (
142-
$varOutput !== EXPECTED_OUTPUT_VALID_OFFSETS
255+
!preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput)
143256
&& !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput)
144257
&& !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput)
145258
&& $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS

Zend/tests/offsets/invalid_container_offset_behaviour.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ null coalesce:
3838
string(7) "default"
3939
unset():
4040
Cannot unset offset in a non-array variable
41+
Nested read:
42+
43+
Warning: Trying to access array offset on $containerStr in %s on line 62
44+
45+
Warning: Trying to access array offset on null in %s on line 62
46+
NULL
47+
Nested write:
48+
Cannot use a scalar value as an array
49+
Nested Read-Write:
50+
Cannot use a scalar value as an array
51+
Nested isset():
52+
bool(false)
53+
Nested empty():
54+
bool(true)
55+
Nested null coalesce:
56+
string(7) "default"
57+
Nested unset():
58+
Cannot unset offset in a non-array variable
4159
4260
OUTPUT;
4361

0 commit comments

Comments
 (0)