1515use Symfony \Component \VarDumper \Caster \Caster ;
1616use Symfony \Component \VarDumper \Caster \ExceptionCaster ;
1717use Symfony \Component \VarDumper \Caster \FrameStub ;
18+ use Symfony \Component \VarDumper \Caster \TraceStub ;
1819use Symfony \Component \VarDumper \Cloner \VarCloner ;
20+ use Symfony \Component \VarDumper \Dumper \CliDumper ;
1921use Symfony \Component \VarDumper \Dumper \HtmlDumper ;
2022use Symfony \Component \VarDumper \Test \VarDumperTestTrait ;
23+ use Symfony \Component \VarDumper \Tests \Fixtures \DumpClassWithErrors ;
2124
2225class ExceptionCasterTest extends TestCase
2326{
@@ -44,15 +47,15 @@ public function testDefaultSettings()
4447 #message: "foo"
4548 #code: 0
4649 #file: "%sExceptionCasterTest.php"
47- #line: 28
50+ #line: %d
4851 trace: {
49- %s%eTests%eCaster%eExceptionCasterTest.php:28 {
52+ %s%eTests%eCaster%eExceptionCasterTest.php:%d {
5053 Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
5154 › {
5255 › return new \Exception(''.$msg);
5356 › }
5457 }
55- %s%eTests%eCaster%eExceptionCasterTest.php:40 { …}
58+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
5659%A
5760EODUMP;
5861
@@ -66,13 +69,13 @@ public function testSeek()
6669
6770 $ expectedDump = <<<'EODUMP'
6871{
69- %s%eTests%eCaster%eExceptionCasterTest.php:28 {
72+ %s%eTests%eCaster%eExceptionCasterTest.php:%d {
7073 Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
7174 › {
7275 › return new \Exception(''.$msg);
7376 › }
7477 }
75- %s%eTests%eCaster%eExceptionCasterTest.php:65 { …}
78+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
7679%A
7780EODUMP;
7881
@@ -89,15 +92,15 @@ public function testNoArgs()
8992 #message: "1"
9093 #code: 0
9194 #file: "%sExceptionCasterTest.php"
92- #line: 28
95+ #line: %d
9396 trace: {
94- %sExceptionCasterTest.php:28 {
97+ %sExceptionCasterTest.php:%d {
9598 Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
9699 › {
97100 › return new \Exception(''.$msg);
98101 › }
99102 }
100- %s%eTests%eCaster%eExceptionCasterTest.php:84 { …}
103+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
101104%A
102105EODUMP;
103106
@@ -114,16 +117,40 @@ public function testNoSrcContext()
114117 #message: "1"
115118 #code: 0
116119 #file: "%sExceptionCasterTest.php"
117- #line: 28
120+ #line: %d
118121 trace: {
119- %s%eTests%eCaster%eExceptionCasterTest.php:28
122+ %s%eTests%eCaster%eExceptionCasterTest.php:%d
120123 %s%eTests%eCaster%eExceptionCasterTest.php:%d
121124%A
122125EODUMP;
123126
124127 $ this ->assertDumpMatchesFormat ($ expectedDump , $ e );
125128 }
126129
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+
127154 public function testHtmlDump ()
128155 {
129156 if (ini_get ('xdebug.file_link_format ' ) || get_cfg_var ('xdebug.file_link_format ' )) {
@@ -146,10 +173,10 @@ public function testHtmlDump()
146173 #<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span>
147174 #<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php
148175%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>
150177 <span class=sf-dump-meta>trace</span>: {<samp>
151178 <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>
153180 …%d
154181 </samp>}
155182</samp>}
@@ -169,12 +196,12 @@ public function testFrameWithTwig()
169196 $ f = [
170197 new FrameStub ([
171198 'file ' => \dirname (__DIR__ ).'/Fixtures/Twig.php ' ,
172- 'line ' => 20 ,
199+ 'line ' => 33 ,
173200 'class ' => '__TwigTemplate_VarDumperFixture_u75a09 ' ,
174201 ]),
175202 new FrameStub ([
176203 'file ' => \dirname (__DIR__ ).'/Fixtures/Twig.php ' ,
177- 'line ' => 21 ,
204+ 'line ' => 34 ,
178205 'class ' => '__TwigTemplate_VarDumperFixture_u75a09 ' ,
179206 'object ' => new \__TwigTemplate_VarDumperFixture_u75a09 (null , __FILE__ ),
180207 ]),
@@ -186,7 +213,7 @@ public function testFrameWithTwig()
186213 class: "__TwigTemplate_VarDumperFixture_u75a09"
187214 src: {
188215 %sTwig.php:1 {
189- ›
216+ ›%s
190217 › foo bar
191218 › twig source
192219 }
@@ -201,12 +228,11 @@ class: "__TwigTemplate_VarDumperFixture_u75a09"
201228 %sExceptionCasterTest.php:2 {
202229 › foo bar
203230 › twig source
204- ›
231+ ›%s
205232 }
206233 }
207234 }
208235]
209-
210236EODUMP;
211237
212238 $ this ->assertDumpMatchesFormat ($ expectedDump , $ f );
@@ -221,7 +247,7 @@ public function testExcludeVerbosity()
221247 #message: "foo"
222248 #code: 0
223249 #file: "%sExceptionCasterTest.php"
224- #line: 28
250+ #line: %d
225251}
226252EODUMP;
227253
0 commit comments