Skip to content

Commit 5af976a

Browse files
committed
Update UnitTests (php < 7.0 and int prop names)
1 parent be87f14 commit 5af976a

1 file changed

Lines changed: 52 additions & 33 deletions

File tree

tests/Debug/Type/ObjectTest.php

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -253,34 +253,42 @@ static function ($foo, $bar) {
253253
'value' => '',
254254
),
255255
), Helper::deObjectifyData($abs['keys']));
256-
self::assertSame(array(
256+
$keysExpect = array(
257257
"\xE2\x80\x8B",
258258
"\xef\xbb\xbf",
259259
"\xef\xbb\xbfbom\r\n\t\x07 \x1F \x7F \xc2\xa0<i>(nbsp)</i> \xE2\x80\x89(thsp), & \xE2\x80\x8B(zwsp)",
260260
' ',
261261
// '',
262262
42,
263263
'ade50251dade9edc27e822ebdc3e9664',
264-
), \array_keys($abs['properties']));
264+
);
265+
if (PHP_VERSION_ID < 70000) {
266+
$index = \array_search(42, $keysExpect, true);
267+
\array_splice($keysExpect, $index, 1);
268+
}
269+
self::assertSame($keysExpect, \array_keys($abs['properties']));
265270
},
266-
'streamAnsi' => \str_replace('\e', "\e", '
267-
\e[1mstdClass\e[22m
268-
\e[38;5;245m[\e[38;5;83m \e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mspace\e[38;5;250m"\e[0m
269-
\e[38;5;245m[\e[38;5;83m\e[96m42\e[0m\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mint key\e[38;5;250m"\e[0m
270-
\e[38;5;245m[\e[38;5;83mnot\e[30;48;5;250m80\e[0m\e[34;48;5;14mυ\e[0mtf8\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mnot utf8\e[38;5;250m"\e[0m
271-
\e[38;5;245m[\e[38;5;83m\e[34;48;5;14m\u{200b}\e[0m\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mzwsp\e[38;5;250m"\e[0m
272-
\e[38;5;245m[\e[38;5;83m\e[34;48;5;14m\u{feff}\e[0m\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mbom\e[38;5;250m"\e[0m
273-
\e[38;5;245m[\e[38;5;83m\e[34;48;5;14m\u{feff}\e[0mbom[\r]
274-
\e[34;48;5;14m\x07\e[0m \e[34;48;5;14m\x1f\e[0m \e[34;48;5;14m\x7f\e[0m \e[34;48;5;14m\u{00a0}\e[0m<i>(nbsp)</i> \e[34;48;5;14m\u{2009}\e[0m(thsp), & \e[34;48;5;14m\u{200b}\e[0m(zwsp)\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mctrl chars and whatnot\e[38;5;250m"\e[0m
275-
'),
276-
'text' => 'stdClass
277-
[ ] => "space"
278-
[42] => "int key"
279-
[not\x80\u{03c5}tf8] => "not utf8"
280-
[\u{200b}] => "zwsp"
281-
[\u{feff}] => "bom"
282-
[\u{feff}bom[\r]
283-
\x07 \x1f \x7f \u{00a0}<i>(nbsp)</i> \u{2009}(thsp), & \u{200b}(zwsp)] => "ctrl chars and whatnot"',
271+
'streamAnsi' => \str_replace('\e', "\e", '\e[1mstdClass\e[22m' . "\n"
272+
. '\e[38;5;245m[\e[38;5;83m \e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mspace\e[38;5;250m"\e[0m' . "\n"
273+
. (PHP_VERSION_ID >= 80200
274+
? '\e[38;5;245m[\e[38;5;83m\e[96m42\e[0m\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mint key\e[38;5;250m"\e[0m' . "\n"
275+
: '')
276+
. '\e[38;5;245m[\e[38;5;83mnot\e[30;48;5;250m80\e[0m\e[34;48;5;14mυ\e[0mtf8\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mnot utf8\e[38;5;250m"\e[0m' . "\n"
277+
. '\e[38;5;245m[\e[38;5;83m\e[34;48;5;14m\u{200b}\e[0m\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mzwsp\e[38;5;250m"\e[0m' . "\n"
278+
. '\e[38;5;245m[\e[38;5;83m\e[34;48;5;14m\u{feff}\e[0m\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mbom\e[38;5;250m"\e[0m' . "\n"
279+
. '\e[38;5;245m[\e[38;5;83m\e[34;48;5;14m\u{feff}\e[0mbom[\r]' . "\n"
280+
. '\e[34;48;5;14m\x07\e[0m \e[34;48;5;14m\x1f\e[0m \e[34;48;5;14m\x7f\e[0m \e[34;48;5;14m\u{00a0}\e[0m<i>(nbsp)</i> \e[34;48;5;14m\u{2009}\e[0m(thsp), & \e[34;48;5;14m\u{200b}\e[0m(zwsp)\e[38;5;245m]\e[0m \e[38;5;224m=>\e[0m \e[38;5;250m"\e[0mctrl chars and whatnot\e[38;5;250m"\e[0m'
281+
),
282+
'text' => 'stdClass' . "\n"
283+
. '[ ] => "space"' . "\n"
284+
. (PHP_VERSION_ID >= 80200
285+
? '[42] => "int key"' . "\n"
286+
: '')
287+
. '[not\x80\u{03c5}tf8] => "not utf8"' . "\n"
288+
. '[\u{200b}] => "zwsp"' . "\n"
289+
. '[\u{feff}] => "bom"' . "\n"
290+
. '[\u{feff}bom[\r]' . "\n"
291+
. '\x07 \x1f \x7f \u{00a0}<i>(nbsp)</i> \u{2009}(thsp), & \u{200b}(zwsp)] => "ctrl chars and whatnot"',
284292
),
285293
),
286294

@@ -296,10 +304,15 @@ static function ($foo, $bar) {
296304
array(
297305
'entry' => static function (LogEntry $logEntry) {
298306
$abs = $logEntry['args'][0];
299-
self::assertSame(array(
307+
$keysExpect = array(
300308
'foo',
301309
42,
302-
), \array_keys($abs['properties']));
310+
);
311+
if (PHP_VERSION_ID < 70000) {
312+
$index = \array_search(42, $keysExpect, true);
313+
\array_splice($keysExpect, $index, 1);
314+
}
315+
self::assertSame($keysExpect, \array_keys($abs['properties']));
303316
},
304317
'html' => '<li class="m_log"><div class="groupByInheritance t_object" data-accessible="public"><span class="t_identifier" data-type-more="className"><span class="classname">stdClass</span></span>' . "\n"
305318
. '<dl class="object-inner">' . "\n"
@@ -309,21 +322,27 @@ static function ($foo, $bar) {
309322
. '<dd class="attribute"><span class="classname">AllowDynamicProperties</span></dd>' . "\n"
310323
: '')
311324
. '<dt class="properties">properties</dt>' . "\n"
312-
. '<dd class="property public"><span class="t_modifier_public">public</span> <span class="no-quotes t_identifier t_int">42</span> <span class="t_operator">=</span> <span class="t_string">int key</span></dd>' . "\n"
325+
. (PHP_VERSION_ID >= 70000
326+
? '<dd class="property public"><span class="t_modifier_public">public</span> <span class="no-quotes t_identifier t_int">42</span> <span class="t_operator">=</span> <span class="t_string">int key</span></dd>' . "\n"
327+
: '')
313328
. '<dd class="property public"><span class="t_modifier_public">public</span> <span class="no-quotes t_identifier t_string">foo</span> <span class="t_operator">=</span> <span class="t_string">bar</span></dd>' . "\n"
314329
. '<dt class="methods">no methods</dt>' . "\n"
315330
. '</dl>' . "\n"
316331
. '</div></li>',
317-
'streamAnsi' => \str_replace('\e', "\e", '\e[1mstdClass\e[22m
318-
\e[4mproperties:\e[24m
319-
\e[38;5;250m(public)\e[0m \e[38;5;83m\e[96m42\e[38;5;83;49m\e[0m \e[38;5;224m=\e[0m \e[38;5;250m"\e[0mint key\e[38;5;250m"\e[0m
320-
\e[38;5;250m(public)\e[0m \e[38;5;83mfoo\e[0m \e[38;5;224m=\e[0m \e[38;5;250m"\e[0mbar\e[38;5;250m"\e[0m
321-
no methods'),
322-
'text' => 'stdClass
323-
properties:
324-
(public) 42 = "int key"
325-
(public) foo = "bar"
326-
no methods',
332+
'streamAnsi' => \str_replace('\e', "\e", '\e[1mstdClass\e[22m' . "\n"
333+
. '\e[4mproperties:\e[24m' . "\n"
334+
. (PHP_VERSION_ID >= 70000
335+
? '\e[38;5;250m(public)\e[0m \e[38;5;83m\e[96m42\e[38;5;83;49m\e[0m \e[38;5;224m=\e[0m \e[38;5;250m"\e[0mint key\e[38;5;250m"\e[0m' . "\n"
336+
: '')
337+
. '\e[38;5;250m(public)\e[0m \e[38;5;83mfoo\e[0m \e[38;5;224m=\e[0m \e[38;5;250m"\e[0mbar\e[38;5;250m"\e[0m' . "\n"
338+
. 'no methods'),
339+
'text' => 'stdClass' . "\n"
340+
. 'properties:' . "\n"
341+
. (PHP_VERSION_ID >= 70000
342+
? ' (public) 42 = "int key"' . "\n"
343+
: '')
344+
. ' (public) foo = "bar"' . "\n"
345+
. 'no methods',
327346
),
328347
),
329348

0 commit comments

Comments
 (0)