8000 [PhpUnitBridge] Fix error when setting "self" property value · symfony/symfony@179b76e · GitHub
[go: up one dir, main page]

Skip to content

Commit 179b76e

Browse files
l-vogreg0ire
authored andcommitted
[PhpUnitBridge] Fix error when setting "self" property value
1 parent 6b3bbe4 commit 179b76e

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1616
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
17+
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5;
1718

1819
class DeprecationTest extends TestCase
1920
{
@@ -118,9 +119,60 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles()
118119
$this->assertTrue($deprecation->isMuted());
119120
}
120121

122+
public function providerIsSelf(): array
123+
{
124+
return [
125+
'not_from_vendors_file' => [true, '', 'MyClass1', ''],
126+
'nonexistent_file' => [false, '', 'MyClass1', 'dummy_vendor_path'],
127+
'serialized_trace_without_triggering_file' => [
128+
true,
129+
serialize(['class' => '', 'method' => '', 'deprecation' => '', 'files_stack' => []]),
130+
SymfonyTestsListenerForV5::class,
131+
'',
132+
],
133+
'serialized_trace_with_not_from_vendors_triggering_file' => [
134+
true,
135+
serialize([
136+
'class' => '',
137+
'method' => '',
138+
'deprecation' => '',
139+
'triggering_file' => '',
140+
'files_stack' => [],
141+
]),
142+
SymfonyTestsListenerForV5::class,
143+
'',
144+
],
145+
'serialized_trace_with_nonexistent_triggering_file' => [
146+
false,
147+
serialize([
148+
'class' => '',
149+
'method' => '',
150+
'deprecation' => '',
151+
'triggering_file' => 'dummy_vendor_path',
152+
'files_stack' => [],
153+
]),
154+
SymfonyTestsListenerForV5::class,
155+
'',
156+
],
157+
];
158+
}
159+
160+
/**
161+
* @dataProvider providerIsSelf
162+
*/
163+
public function testIsSelf(bool $expectedIsSelf, string $message, string $traceClass, string $file): void
164+
{
165+
$trace = [
166+
['class' => 'MyClass1', 'function' => 'myMethod'],
167+
['class' => $traceClass, 'function' => 'myMethod'],
168+
];
169+
$deprecation = new Deprecation($message, $trace, $file);
170+
$this->assertEquals($expectedIsSelf, $deprecation->getType() === Deprecation::TYPE_SELF);
171+
}
172+
121173
/**
122174
* This method is here to simulate the extra level from the piece of code
123-
* triggering an error to the error handler
175+
* triggering an error to the error handler.
124176
*/
125177
public function debugBacktrace(): array
126178
{

0 commit comments

Comments
 (0)
0