Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9c00d21

Browse filesBrowse files
[VarDumper] Fix tests for PHP 8.1
1 parent 0fa07c6 commit 9c00d21
Copy full SHA for 9c00d21

File tree

1 file changed

+73
-7
lines changed
Filter options

1 file changed

+73
-7
lines changed

‎src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php
+73-7Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,31 @@ public function testReflectionParameter()
122122
{
123123
$var = new \ReflectionParameter(reflectionParameterFixture::class, 0);
124124

125-
$this->assertDumpMatchesFormat(
126-
<<<'EOTXT'
125+
if (\PHP_VERSION_ID < 80100) {
126+
$this->assertDumpMatchesFormat(
127+
<<<'EOTXT'
127128
ReflectionParameter {
128129
+name: "arg1"
129130
position: 0
130131
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
131132
default: null
132133
}
133134
EOTXT
134-
, $var
135-
);
135+
, $var
136+
);
137+
} else {
138+
$this->assertDumpMatchesFormat(
139+
<<<'EOTXT'
140+
ReflectionParameter {
141+
+name: "arg1"
142+
position: 0
143+
allowsNull: true
144+
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
145+
}
146+
EOTXT
147+
, $var
148+
);
149+
}
136150
}
137151

138152
public function testReflectionParameterScalar()
@@ -406,7 +420,8 @@ public function testGenerator()
406420
$generator = new GeneratorDemo();
407421
$generator = $generator->baz();
408422

409-
$expectedDump = <<<'EODUMP'
423+
if (\PHP_VERSION_ID < 80100) {
424+
$expectedDump = <<<'EODUMP'
410425
Generator {
411426
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
412427
executing: {
@@ -420,14 +435,32 @@ public function testGenerator()
420435
closed: false
421436
}
422437
EODUMP;
438+
} else {
439+
$expectedDump = <<<'EODUMP'
440+
Generator {
441+
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
442+
trace: {
443+
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:13 {
444+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
445+
› public function baz()
446+
› {
447+
› yield from bar();
448+
}
449+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
450+
}
451+
closed: false
452+
}
453+
EODUMP;
454+
}
423455

424456
$this->assertDumpMatchesFormat($expectedDump, $generator);
425457

426458
foreach ($generator as $v) {
427459
break;
428460
}
429461

430-
$expectedDump = <<<'EODUMP'
462+
if (\PHP_VERSION_ID < 80100) {
463+
$expectedDump = <<<'EODUMP'
431464
array:2 [
432465
0 => ReflectionGenerator {
433466
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
@@ -449,13 +482,46 @@ public function testGenerator()
449482
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
450483
› yield 1;
451484
› }
452-
485+
453486
}
454487
}
455488
closed: false
456489
}
457490
]
458491
EODUMP;
492+
} else {
493+
$expectedDump = <<<'EODUMP'
494+
array:2 [
495+
0 => ReflectionGenerator {
496+
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
497+
trace: {
498+
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
499+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
500+
› {
501+
› yield 1;
502+
› }
503+
}
504+
%s%eTests%eFixtures%eGeneratorDemo.php:20 { …}
505+
%s%eTests%eFixtures%eGeneratorDemo.php:14 { …}
506+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
507+
}
508+
closed: false
509+
}
510+
1 => Generator {
511+
trace: {
512+
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:9 {
513+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
514+
› {
515+
› yield 1;
516+
› }
517+
}
518+
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {}
519+
}
520+
closed: false
521+
}
522+
]
523+
EODUMP;
524+
}
459525

460526
$r = new \ReflectionGenerator($generator);
461527
$this->assertDumpMatchesFormat($expectedDump, [$r, $r->getExecutingGenerator()]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.