15
15
use Symfony \Component \VarDumper \Caster \Caster ;
16
16
use Symfony \Component \VarDumper \Caster \ExceptionCaster ;
17
17
use Symfony \Component \VarDumper \Caster \FrameStub ;
18
+ use Symfony \Component \VarDumper \Caster \TraceStub ;
18
19
use Symfony \Component \VarDumper \Cloner \VarCloner ;
20
+ use Symfony \Component \VarDumper \Dumper \CliDumper ;
19
21
use Symfony \Component \VarDumper \Dumper \HtmlDumper ;
20
22
use Symfony \Component \VarDumper \Test \VarDumperTestTrait ;
23
+ use Symfony \Component \VarDumper \Tests \Fixtures \DumpClassWithErrors ;
21
24
22
25
class ExceptionCasterTest extends TestCase
23
26
{
@@ -44,15 +47,15 @@ public function testDefaultSettings()
44
47
#message: "foo"
45
48
#code: 0
46
49
#file: "%sExceptionCasterTest.php"
47
- #line: 28
50
+ #line: %d
48
51
trace: {
49
- %s%eTests%eCaster%eExceptionCasterTest.php:28 {
52
+ %s%eTests%eCaster%eExceptionCasterTest.php:%d {
50
53
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
51
54
› {
52
55
› return new \Exception(''.$msg);
53
56
› }
54
57
}
55
- %s%eTests%eCaster%eExceptionCasterTest.php:40 { …}
58
+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
56
59
%A
57
60
EODUMP;
58
61
@@ -66,13 +69,13 @@ public function testSeek()
66
69
67
70
$ expectedDump = <<<'EODUMP'
68
71
{
69
- %s%eTests%eCaster%eExceptionCasterTest.php:28 {
72
+ %s%eTests%eCaster%eExceptionCasterTest.php:%d {
70
73
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
71
74
› {
72
75
› return new \Exception(''.$msg);
73
76
› }
74
77
}
75
- %s%eTests%eCaster%eExceptionCasterTest.php:65 { …}
78
+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
76
79
%A
77
80
EODUMP;
78
81
@@ -89,15 +92,15 @@ public function testNoArgs()
89
92
#message: "1"
90
93
#code: 0
91
94
#file: "%sExceptionCasterTest.php"
92
- #line: 28
95
+ #line: %d
93
96
trace: {
94
- %sExceptionCasterTest.php:28 {
97
+ %sExceptionCasterTest.php:%d {
95
98
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
96
99
› {
97
100
› return new \Exception(''.$msg);
98
101
› }
99
102
}
100
- %s%eTests%eCaster%eExceptionCasterTest.php:84 { …}
103
+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
101
104
%A
102
105
EODUMP;
103
106
@@ -114,16 +117,40 @@ public function testNoSrcContext()
114
117
#message: "1"
115
118
#code: 0
116
119
#file: "%sExceptionCasterTest.php"
117
- #line: 28
120
+ #line: %d
118
121
trace: {
119
- %s%eTests%eCaster%eExceptionCasterTest.php:28
122
+ %s%eTests%eCaster%eExceptionCasterTest.php:%d
120
123
%s%eTests%eCaster%eExceptionCasterTest.php:%d
121
124
%A
122
125
EODUMP;
123
126
124
127
$ this ->assertDumpMatchesFormat ($ expectedDump , $ e );
125
128
}
126
129
130
+ public function testShouldReturnTraceForConcreteTwigWithError ()
131
+ {
132
+ require_once \dirname (__DIR__ ).'/Fixtures/Twig.php ' ;
133
+
134
+ $ innerExc = (new \__TwigTemplate_VarDumperFixture_u75a09 (null , __FILE__ ))->provideError ();
135
+ $ nestingWrapper = new \stdClass ();
136
+ $ nestingWrapper ->trace = new TraceStub ($ innerExc ->getTrace ());
137
+
138
+ $ expectedDump = <<<'EODUMP'
139
+ {
140
+ +"trace": {
141
+ %sTwig.php:%d {
142
+ AbstractTwigTemplate->provideError()
143
+ › {
144
+ › return $this->createError();
145
+ › }
146
+ }
147
+ %sExceptionCasterTest.php:%d { …}
148
+ %A
149
+ EODUMP;
150
+
151
+ $ this ->assertDumpMatchesFormat ($ expectedDump , $ nestingWrapper );
152
+ }
153
+
127
154
public function testHtmlDump ()
128
155
{
129
156
if (ini_get ('xdebug.file_link_format ' ) || get_cfg_var ('xdebug.file_link_format ' )) {
@@ -146,10 +173,10 @@ public function testHtmlDump()
146
173
#<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span>
147
174
#<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php
148
175
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%e</span>Tests%eCaster%eExceptionCasterTest.php</span>"
149
- #<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>28 </span>
176
+ #<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>%d </span>
150
177
<span class=sf-dump-meta>trace</span>: {<samp>
151
178
<span class=sf-dump-meta title="%sExceptionCasterTest.php
152
- Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%e</span>Tests%eCaster%eExceptionCasterTest.php</span>:<span class=sf-dump-num>28 </span>
179
+ Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%e</span>Tests%eCaster%eExceptionCasterTest.php</span>:<span class=sf-dump-num>%d </span>
153
180
…%d
154
181
</samp>}
155
182
</samp>}
@@ -169,12 +196,12 @@ public function testFrameWithTwig()
169
196
$ f = [
170
197
new FrameStub ([
171
198
'file ' => \dirname (__DIR__ ).'/Fixtures/Twig.php ' ,
172
- 'line ' => 20 ,
199
+ 'line ' => 33 ,
173
200
'class ' => '__TwigTemplate_VarDumperFixture_u75a09 ' ,
174
201
]),
175
202
new FrameStub ([
176
203
'file ' => \dirname (__DIR__ ).'/Fixtures/Twig.php ' ,
177
- 'line ' => 21 ,
204
+ 'line ' => 34 ,
178
205
'class ' => '__TwigTemplate_VarDumperFixture_u75a09 ' ,
179
206
'object ' => new \__TwigTemplate_VarDumperFixture_u75a09 (null , __FILE__ ),
180
207
]),
@@ -186,7 +213,7 @@ public function testFrameWithTwig()
186
213
class: "__TwigTemplate_VarDumperFixture_u75a09"
187
214
src: {
188
215
%sTwig.php:1 {
189
- ›
216
+ ›%s
190
217
› foo bar
191
218
› twig source
192
219
}
@@ -201,12 +228,11 @@ class: "__TwigTemplate_VarDumperFixture_u75a09"
201
228
%sExceptionCasterTest.php:2 {
202
229
› foo bar
203
230
› twig source
204
- ›
231
+ ›%s
205
232
}
206
233
}
207
234
}
208
235
]
209
-
210
236
EODUMP;
211
237
212
238
$ this ->assertDumpMatchesFormat ($ expectedDump , $ f );
@@ -221,7 +247,7 @@ public function testExcludeVerbosity()
221
247
#message: "foo"
222
248
#code: 0
223
249
#file: "%sExceptionCasterTest.php"
224
- #line: 28
250
+ #line: %d
225
251
}
226
252
EODUMP;
227
253
0 commit comments