|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
|
| 16 | +use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5; |
16 | 17 |
|
17 | 18 | class DeprecationTest extends TestCase
|
18 | 19 | {
|
@@ -56,9 +57,60 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect()
|
56 | 57 | $this->assertFalse($deprecation->isIndirect());
|
57 | 58 | }
|
58 | 59 |
|
| 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 | + |
59 | 111 | /**
|
60 | 112 | * 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. |
62 | 114 | */
|
63 | 115 | public function debugBacktrace(): array
|
64 | 116 | {
|
|
0 commit comments