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

Skip to content

Commit 75461d0

Browse files
committed
[PhpUnitBridge] Fix error when setting "self" property value
1 parent fc86d10 commit 75461d0

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function __construct($message, array $trace, $file)
7070
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
7171
// then we need to use the serialized information to determine
7272
// if the error has been triggered from vendor code.
73-
$this->self = isset($parsedMsg['triggering_file'])
74-
&& $this->pathOriginatesFromVendor($parsedMsg['triggering_file']);
73+
$this->self = !isset($parsedMsg['triggering_file'])
74+
|| !$this->pathOriginatesFromVendor($parsedMsg['triggering_file']);
7575

7676
return;
7777
}

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,60 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect()
5656
$this->assertFalse($deprecation->isIndirect());
5757
}
5858

59+
public function providerIsSelf(): array
60+
{
61+
return [
62+
'not_from_vendors_file' => [true, '', 'MyClass1', ''],
63+
'nonexistent_file' => [false, '', 'MyClass1', 'dummy_vendor_path'],
64+
'serialized_trace_without_triggering_file' => [
65+
true,
66+
serialize(['class' => '', 'method' => '', 'deprecation' => '', 'files_stack' => []]),
67+
SymfonyTestsListenerForV5::class,
68+
'',
69+
],
70+
'serialized_trace_with_not_from_vendors_triggering_file' => [
71+
true,
72+
serialize([
73+
'class' => '',
74+
'method' => '',
75+
'deprecation' => '',
76+
'triggering_file' => '',
77+
'files_stack' => [],
78+
]),
79+
SymfonyTestsListenerForV5::class,
80+
'',
81+
],
82+
'serialized_trace_with_nonexistent_triggering_file' => [
83+
false,
84+
serialize([
85+
'class' => '',
86+
'method' => '',
87+
'deprecation' => '',
88+
'triggering_file' => 'dummy_vendor_path',
89+
'files_stack' => [],
90+
]),
91+
SymfonyTestsListenerForV5::class,
92+
'',
93+
],
94+
];
95+
}
96+
97+
/**
98+
* @dataProvider providerIsSelf
99+
*/
100+
public function testIsSelf(bool $expectedIsSelf, string $message, string $traceClass, string $file): void
101+
{
102+
$trace = [
103+
['class' => 'MyClass1', 'function' => 'myMethod'],
104+
['class' => $traceClass, 'function' => 'myMethod'],
105+
];
106+
$deprecation = new Deprecation($message, $trace, $file);
107+
$this->assertEquals($expectedIsSelf, $deprecation->isSelf());
108+
}
109+
59110
/**
60111
* This method is here to simulate the extra level from the piece of code
61-
* triggering an error to the error handler
112+
* triggering an error to the error handler.
62113
*/
63114
public function debugBacktrace(): array
64115
{

0 commit comments

Comments
 (0)
0