|
58 | 58 | }); |
59 | 59 |
|
60 | 60 | test('it replaces base path in stack traces', function () { |
61 | | - $formatter = new StackTraceFormatter(); |
| 61 | + $formatter = new StackTraceFormatter; |
62 | 62 | $basePath = base_path(); |
63 | 63 |
|
64 | 64 | $stackTrace = <<<TRACE |
|
69 | 69 |
|
70 | 70 | // Test simplified trace (with vendor frame collapsing) |
71 | 71 | expect($formatter->format($stackTrace, true)) |
72 | | - ->toBe(<<<TRACE |
73 | | -#00 /app/Services/ImageService.php(25): Spatie\\Image\\Image->loadFile() |
| 72 | + ->toBe(<<<'TRACE' |
| 73 | +#00 /app/Services/ImageService.php(25): Spatie\Image\Image->loadFile() |
74 | 74 | [Vendor frames] |
75 | 75 | TRACE |
76 | 76 | ); |
77 | 77 |
|
78 | 78 | // Test full trace (without vendor frame collapsing) |
79 | 79 | expect($formatter->format($stackTrace, false)) |
80 | | - ->toBe(<<<TRACE |
81 | | -#00 /app/Services/ImageService.php(25): Spatie\\Image\\Image->loadFile() |
82 | | -#01 /vendor/laravel/framework/src/Foundation/Application.php(1235): App\\Services\\ImageService->process() |
83 | | -#02 /artisan(13): Illuminate\\Foundation\\Application->run() |
| 80 | + ->toBe(<<<'TRACE' |
| 81 | +#00 /app/Services/ImageService.php(25): Spatie\Image\Image->loadFile() |
| 82 | +#01 /vendor/laravel/framework/src/Foundation/Application.php(1235): App\Services\ImageService->process() |
| 83 | +#02 /artisan(13): Illuminate\Foundation\Application->run() |
84 | 84 | TRACE |
85 | 85 | ); |
86 | 86 | }); |
87 | 87 |
|
88 | 88 | test('it handles empty base path correctly', function () { |
89 | | - $formatter = new StackTraceFormatter(); |
| 89 | + $formatter = new StackTraceFormatter; |
90 | 90 |
|
91 | | - $stackTrace = <<<TRACE |
| 91 | + $stackTrace = <<<'TRACE' |
92 | 92 | #0 /absolute/path/to/app/Services/ImageService.php(25): someMethod() |
93 | 93 | #1 /vendor/package/src/File.php(10): otherMethod() |
94 | 94 | TRACE; |
95 | 95 |
|
96 | 96 | $result = $formatter->format($stackTrace, true); |
97 | 97 |
|
98 | 98 | expect($result) |
99 | | - ->toBe(<<<TRACE |
| 99 | + ->toBe(<<<'TRACE' |
100 | 100 | #00 /absolute/path/to/app/Services/ImageService.php(25): someMethod() |
101 | 101 | [Vendor frames] |
102 | 102 | TRACE |
103 | 103 | ); |
104 | 104 | }); |
105 | 105 |
|
106 | 106 | test('it preserves non-stack-trace lines', function () { |
107 | | - $formatter = new StackTraceFormatter(); |
| 107 | + $formatter = new StackTraceFormatter; |
108 | 108 |
|
109 | | - $stackTrace = <<<TRACE |
| 109 | + $stackTrace = <<<'TRACE' |
110 | 110 | [2024-03-21 12:00:00] Error: Something went wrong |
111 | 111 | #0 /app/Services/Service.php(25): someMethod() |
112 | 112 | #1 /vendor/package/src/File.php(10): otherMethod() |
|
115 | 115 | $result = $formatter->format($stackTrace, true); |
116 | 116 |
|
117 | 117 | expect($result) |
118 | | - ->toBe(<<<TRACE |
| 118 | + ->toBe(<<<'TRACE' |
119 | 119 | [2024-03-21 12:00:00] Error: Something went wrong |
120 | 120 | #00 /app/Services/Service.php(25): someMethod() |
121 | 121 | [Vendor frames] |
|
124 | 124 | }); |
125 | 125 |
|
126 | 126 | test('it recognizes artisan lines as vendor frames', function () { |
127 | | - $formatter = new StackTraceFormatter(); |
| 127 | + $formatter = new StackTraceFormatter; |
128 | 128 | $basePath = base_path(); |
129 | 129 |
|
130 | 130 | $stackTrace = <<<TRACE |
|
135 | 135 |
|
136 | 136 | // Test simplified trace (with vendor frame collapsing) |
137 | 137 | expect($formatter->format($stackTrace, true)) |
138 | | - ->toBe(<<<TRACE |
| 138 | + ->toBe(<<<'TRACE' |
139 | 139 | #00 /app/Console/Commands/ImportCommand.php(25): handle() |
140 | 140 | [Vendor frames] |
141 | 141 | TRACE |
142 | 142 | ); |
143 | 143 |
|
144 | 144 | // Test that artisan lines are preserved in full trace |
145 | 145 | expect($formatter->format($stackTrace, false)) |
146 | | - ->toBe(<<<TRACE |
| 146 | + ->toBe(<<<'TRACE' |
147 | 147 | #00 /app/Console/Commands/ImportCommand.php(25): handle() |
148 | | -#01 /artisan(13): Illuminate\\Foundation\\Application->run() |
| 148 | +#01 /artisan(13): Illuminate\Foundation\Application->run() |
149 | 149 | #02 /artisan(37): require() |
150 | 150 | TRACE |
151 | 151 | ); |
152 | 152 | }); |
153 | 153 |
|
154 | 154 | test('it collapses multiple artisan lines into single vendor frame', function () { |
155 | | - $formatter = new StackTraceFormatter(); |
| 155 | + $formatter = new StackTraceFormatter; |
156 | 156 |
|
157 | | - $stackTrace = <<<TRACE |
158 | | -#0 /artisan(13): Illuminate\\Foundation\\Application->run() |
| 157 | + $stackTrace = <<<'TRACE' |
| 158 | +#0 /artisan(13): Illuminate\Foundation\Application->run() |
159 | 159 | #1 /vendor/laravel/framework/src/Foundation/Application.php(1235): handle() |
160 | 160 | #2 /artisan(37): require() |
161 | 161 | TRACE; |
|
0 commit comments