bug #41701 [VarDumper] Fix tests for PHP 8.1 (alexandre-daubois)

This PR was merged into the 4.4 branch.

Discussion
----------

[VarDumper] Fix tests for PHP 8.1

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Part of #41552 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | N/A

Commits
-------

f2b0822401 [VarDumper] Fix tests for PHP 8.1
This commit is contained in:
Alexander M. Turek 2021-06-22 22:22:50 +02:00
commit 0c1343f4ee
1 changed files with 72 additions and 6 deletions

View File

@ -122,8 +122,9 @@ EOTXT
{
$var = new \ReflectionParameter(reflectionParameterFixture::class, 0);
$this->assertDumpMatchesFormat(
<<<'EOTXT'
if (\PHP_VERSION_ID < 80100) {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
ReflectionParameter {
+name: "arg1"
position: 0
@ -131,8 +132,21 @@ ReflectionParameter {
default: null
}
EOTXT
, $var
);
, $var
);
} else {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
ReflectionParameter {
+name: "arg1"
position: 0
allowsNull: true
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
}
EOTXT
, $var
);
}
}
public function testReflectionParameterScalar()
@ -406,7 +420,8 @@ EOTXT
$generator = new GeneratorDemo();
$generator = $generator->baz();
$expectedDump = <<<'EODUMP'
if (\PHP_VERSION_ID < 80100) {
$expectedDump = <<<'EODUMP'
Generator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { }
executing: {
@ -420,6 +435,23 @@ Generator {
closed: false
}
EODUMP;
} else {
$expectedDump = <<<'EODUMP'
Generator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { }
trace: {
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:13 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz()
public function baz()
{
yield from bar();
}
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
}
closed: false
}
EODUMP;
}
$this->assertDumpMatchesFormat($expectedDump, $generator);
@ -427,7 +459,8 @@ EODUMP;
break;
}
$expectedDump = <<<'EODUMP'
if (\PHP_VERSION_ID < 80100) {
$expectedDump = <<<'EODUMP'
array:2 [
0 => ReflectionGenerator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { }
@ -456,6 +489,39 @@ array:2 [
}
]
EODUMP;
} else {
$expectedDump = <<<'EODUMP'
array:2 [
0 => ReflectionGenerator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { }
trace: {
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
{
yield 1;
}
}
%s%eTests%eFixtures%eGeneratorDemo.php:20 { }
%s%eTests%eFixtures%eGeneratorDemo.php:14 { }
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {}
}
closed: false
}
1 => Generator {
trace: {
./src/Symfony/Component/VarDumper/Tests/Fixtures/GeneratorDemo.php:9 {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo()
{
yield 1;
}
}
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {}
}
closed: false
}
]
EODUMP;
}
$r = new \ReflectionGenerator($generator);
$this->assertDumpMatchesFormat($expectedDump, [$r, $r->getExecutingGenerator()]);