Skip to content

Commit f2633f7

Browse files
[TwigBridge] add Twig dump() function + tests and fixes
1 parent 8e68fdf commit f2633f7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

DataCollector/DumpDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
169169
$dumper->dump(
170170
$dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth),
171171
function ($line, $depth) use (&$data) {
172-
if (false !==$depth) {
172+
if (-1 !== $depth) {
173173
$data .= str_repeat(' ', $depth).$line."\n";
174174
}
175175
}

Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ public function testDump()
3434

3535
$xDump = array(
3636
array(
37-
'data' => "<!DOCTYPE html><style> pre.sf-dump { background-color: #300a24; white-space: pre; line-height: 1.2em; color: #eee8d5; font-family: monospace, sans-serif; padding: 5px; } .sf-dump span { display: inline; }a.sf-dump-ref {color:#444444}span.sf-dump-num {font-weight:bold;color:#0087FF}span.sf-dump-const {font-weight:bold;color:#0087FF}span.sf-dump-str {font-weight:bold;color:#00D7FF}span.sf-dump-cchr {font-style: italic}span.sf-dump-note {color:#D7AF00}span.sf-dump-ref {color:#444444}span.sf-dump-public {color:#008700}span.sf-dump-protected {color:#D75F00}span.sf-dump-private {color:#D70000}span.sf-dump-meta {color:#005FFF}</style><pre class=sf-dump><span class=sf-dump-0><span class=sf-dump-num>123</span>\n</pre>\n",
37+
'data' => "<pre id=sf-dump><span class=sf-dump-0><span class=sf-dump-num>123</span>\n</span></pre><script>Sfjs.dump.instrument()</script>\n",
3838
'name' => 'DumpDataCollectorTest.php',
3939
'file' => __FILE__,
4040
'line' => $line,
4141
'fileExcerpt' => false,
4242
),
4343
);
44-
$this->assertSame($xDump, $collector->getDumps('html'));
44+
$dump = $collector->getDumps('html');
45+
$this->assertTrue(isset($dump[0]['data']));
46+
$dump[0]['data'] = preg_replace('/^.*?<pre/', '<pre', $dump[0]['data']);
47+
$this->assertSame($xDump, $dump);
4548

4649
$this->assertStringStartsWith(
4750
'a:1:{i:0;a:5:{s:4:"data";O:39:"Symfony\Component\VarDumper\Cloner\Data":3:{s:45:"Symfony\Component\VarDumper\Cloner\Datadata";a:1:{i:0;a:1:{i:0;i:123;}}s:49:"Symfony\Component\VarDumper\Cloner\DatamaxDepth";i:-1;s:57:"Symfony\Component\VarDumper\Cloner\DatamaxItemsPerDepth";i:-1;}s:4:"name";s:25:"DumpDataCollectorTest.php";s:4:"file";s:',

0 commit comments

Comments
 (0)