Skip to content

Commit e9cf4df

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

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-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: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
16+
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5;
1617

1718
class DeprecationTest extends TestCase
1819
{
@@ -56,9 +57,60 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect()
5657
$this->assertFalse($deprecation->isIndirect());
5758
}
5859

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy