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 ;
1920use Symfony \Component \VarDumper \Dumper \HtmlDumper ;
2021use Symfony \Component \VarDumper \Test \VarDumperTestTrait ;
@@ -44,15 +45,15 @@ public function testDefaultSettings()
4445 #message: "foo"
4546 #code: 0
4647 #file: "%sExceptionCasterTest.php"
47- #line: 28
48+ #line: %d
4849 trace: {
49- %s%eTests%eCaster%eExceptionCasterTest.php:28 {
50+ %s%eTests%eCaster%eExceptionCasterTest.php:%d {
5051 Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
5152 › {
5253 › return new \Exception(''.$msg);
5354 › }
5455 }
55- %s%eTests%eCaster%eExceptionCasterTest.php:40 { …}
56+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
5657%A
5758EODUMP;
5859
@@ -66,13 +67,13 @@ public function testSeek()
6667
6768 $ expectedDump = <<<'EODUMP'
6869{
69- %s%eTests%eCaster%eExceptionCasterTest.php:28 {
70+ %s%eTests%eCaster%eExceptionCasterTest.php:%d {
7071 Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
7172 › {
7273 › return new \Exception(''.$msg);
7374 › }
7475 }
75- %s%eTests%eCaster%eExceptionCasterTest.php:65 { …}
76+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
7677%A
7778EODUMP;
7879
@@ -89,15 +90,15 @@ public function testNoArgs()
8990 #message: "1"
9091 #code: 0
9192 #file: "%sExceptionCasterTest.php"
92- #line: 28
93+ #line: %d
9394 trace: {
94- %sExceptionCasterTest.php:28 {
95+ %sExceptionCasterTest.php:%d {
9596 Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
9697 › {
9798 › return new \Exception(''.$msg);
9899 › }
99100 }
100- %s%eTests%eCaster%eExceptionCasterTest.php:84 { …}
101+ %s%eTests%eCaster%eExceptionCasterTest.php:%d { …}
101102%A
102103EODUMP;
103104
@@ -114,16 +115,40 @@ public function testNoSrcContext()
114115 #message: "1"
115116 #code: 0
116117 #file: "%sExceptionCasterTest.php"
117- #line: 28
118+ #line: %d
118119 trace: {
119- %s%eTests%eCaster%eExceptionCasterTest.php:28
120+ %s%eTests%eCaster%eExceptionCasterTest.php:%d
120121 %s%eTests%eCaster%eExceptionCasterTest.php:%d
121122%A
122123EODUMP;
123124
124125 $ this ->assertDumpMatchesFormat ($ expectedDump , $ e );
125126 }
126127
128+ public function testShouldReturnTraceForConcreteTwigWithError ()
129+ {
130+ require_once \dirname (__DIR__ ).'/Fixtures/Twig.php ' ;
131+
132+ $ innerExc = (new \__TwigTemplate_VarDumperFixture_u75a09 (null , __FILE__ ))->provideError ();
133+ $ nestingWrapper = new \stdClass ();
134+ $ nestingWrapper ->trace = new TraceStub ($ innerExc ->getTrace ());
135+
136+ $ expectedDump = <<<'EODUMP'
137+ {
138+ +"trace": {
139+ %sTwig.php:%d {
140+ AbstractTwigTemplate->provideError()
141+ › {
142+ › return $this->createError();
143+ › }
144+ }
145+ %sExceptionCasterTest.php:%d { …}
146+ %A
147+ EODUMP;
148+
149+ $ this ->assertDumpMatchesFormat ($ expectedDump , $ nestingWrapper );
150+ }
151+
127152 public function testHtmlDump ()
128153 {
129154 if (ini_get ('xdebug.file_link_format ' ) || get_cfg_var ('xdebug.file_link_format ' )) {
@@ -146,10 +171,10 @@ public function testHtmlDump()
146171 #<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span>
147172 #<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php
148173%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>
174+ #<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>%d </span>
150175 <span class=sf-dump-meta>trace</span>: {<samp data-depth=2 class=sf-dump-compact>
151176 <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>
177+ 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>
153178 …%d
154179 </samp>}
155180</samp>}
@@ -169,12 +194,12 @@ public function testFrameWithTwig()
169194 $ f = [
170195 new FrameStub ([
171196 'file ' => \dirname (__DIR__ ).'/Fixtures/Twig.php ' ,
172- 'line ' => 20 ,
197+ 'line ' => 33 ,
173198 'class ' => '__TwigTemplate_VarDumperFixture_u75a09 ' ,
174199 ]),
175200 new FrameStub ([
176201 'file ' => \dirname (__DIR__ ).'/Fixtures/Twig.php ' ,
177- 'line ' => 21 ,
202+ 'line ' => 34 ,
178203 'class ' => '__TwigTemplate_VarDumperFixture_u75a09 ' ,
179204 'object ' => new \__TwigTemplate_VarDumperFixture_u75a09 (null , __FILE__ ),
180205 ]),
@@ -186,7 +211,7 @@ public function testFrameWithTwig()
186211 class: "__TwigTemplate_VarDumperFixture_u75a09"
187212 src: {
188213 %sTwig.php:1 {
189- ›
214+ ›%s
190215 › foo bar
191216 › twig source
192217 }
@@ -201,12 +226,11 @@ class: "__TwigTemplate_VarDumperFixture_u75a09"
201226 %sExceptionCasterTest.php:2 {
202227 › foo bar
203228 › twig source
204- ›
229+ ›%s
205230 }
206231 }
207232 }
208233]
209-
210234EODUMP;
211235
212236 $ this ->assertDumpMatchesFormat ($ expectedDump , $ f );
@@ -221,7 +245,7 @@ public function testExcludeVerbosity()
221245 #message: "foo"
222246 #code: 0
223247 #file: "%sExceptionCasterTest.php"
224- #line: 28
248+ #line: %d
225249}
226250EODUMP;
227251
0 commit comments