|
14 | 14 | use PHPUnit\Framework\TestCase; |
15 | 15 | use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; |
16 | 16 | use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; |
| 17 | +use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5; |
17 | 18 |
|
18 | 19 | class DeprecationTest extends TestCase |
19 | 20 | { |
@@ -118,9 +119,60 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles() |
118 | 119 | $this->assertTrue($deprecation->isMuted()); |
119 | 120 | } |
120 | 121 |
|
| 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 $
9525
span>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 | + |
121 | 173 | /** |
122 | 174 | * 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. |
124 | 176 | */ |
125 | 177 | public function debugBacktrace(): array |
126 | 178 | { |
|
0 commit comments