diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 3de9a0e91eee7..35d51d3a4cd39 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -77,6 +77,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true) if ($debug) { $this->assertStringStartsWith('\n", - 'name' => 'DumpDataCollectorTest.php', - 'file' => __FILE__, - 'line' => $line, - 'fileExcerpt' => false, + 'data' => "
123\n\n",
+ 'name' => 'DumpDataCollectorTest.php',
+ 'file' => __FILE__,
+ 'line' => $line,
+ 'fileExcerpt' => false,
),
);
- $dump = $collector->getDumps('html');
- $this->assertTrue(isset($dump[0]['data']));
- $dump[0]['data'] = preg_replace('/^.*?assertSame($xDump, $dump);
$this->assertStringStartsWith(
diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
index 6e740c9dcd15b..1f8d72892c397 100644
--- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\VarDumper\Dumper;
use Symfony\Component\VarDumper\Cloner\Cursor;
+use Symfony\Component\VarDumper\Cloner\Data;
/**
* HtmlDumper dumps variables as HTML.
@@ -23,8 +24,9 @@ class HtmlDumper extends CliDumper
public static $defaultOutputStream = 'php://output';
protected $dumpHeader;
- protected $dumpPrefix = '';
+ protected $dumpPrefix = '';
protected $dumpSuffix = '';
+ protected $dumpId = 'sf-dump';
protected $colors = true;
protected $headerIsDumped = false;
protected $lastDepth = -1;
@@ -82,6 +84,15 @@ public function setDumpBoundaries($prefix, $suffix)
$this->dumpSuffix = $suffix;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function dump(Data $data, $lineDumper = null)
+ {
+ $this->dumpId = 'sf-dump-'.mt_rand();
+ parent::dump($data, $lineDumper);
+ }
+
/**
* Dumps the HTML header.
*/
@@ -90,7 +101,7 @@ protected function getDumpHeader()
$this->headerIsDumped = true;
if (null !== $this->dumpHeader) {
- return $this->dumpHeader;
+ return str_replace('%id%', $this->dumpId, $this->dumpHeader);
}
$line = <<<'EOHTML'
@@ -129,7 +140,7 @@ protected function getDumpHeader()
};
'.$this->dumpHeader;
+ $this->dumpHeader = preg_replace('/\s+/', ' ', $line).''.$this->dumpHeader;
+
+ return str_replace('%id%', $this->dumpId, $this->dumpHeader);
}
/**
@@ -201,9 +214,9 @@ protected function style($style, $val)
if ('ref' === $style) {
$ref = substr($val, 1);
if ('#' === $val[0]) {
- return "$val";
+ return "dumpId}-ref$ref\">$val";
} else {
- return "$val";
+ return "dumpId}-ref$ref\">$val";
}
}
@@ -236,14 +249,14 @@ protected function dumpLine($depth)
}
if (-1 === $this->lastDepth) {
- $this->line = $this->dumpPrefix.$this->line;
+ $this->line = str_replace('%id%', $this->dumpId, $this->dumpPrefix).$this->line;
}
if (!$this->headerIsDumped) {
$this->line = $this->getDumpHeader().$this->line;
}
if (-1 === $depth) {
- $this->line .= $this->dumpSuffix;
+ $this->line .= str_replace('%id%', $this->dumpId, $this->dumpSuffix);
parent::dumpLine(0);
}
$this->lastDepth = $depth;
diff --git a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
index e93ff236c238c..82c41b4666dd6 100644
--- a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
@@ -33,7 +33,7 @@ public function testGet()
unset($a['uri']);
return $a;
- }
+ },
));
$data = $cloner->cloneVar($var);
@@ -44,12 +44,14 @@ public function testGet()
$out = preg_replace('/[ \t]+$/m', '', $out);
$var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8');
$intMax = PHP_INT_MAX;
+ preg_match('/sf-dump-(\\d{2,})/', $out, $matches);
+ $dumpId = $matches[1];
$this->assertSame(
<<array:25 [
"" => 1
- => null #1
+ => null #1
"" => 1.1
=> true
=> false
@@ -72,7 +74,7 @@ public function testGet()
: []
}
=> resource:Unknown {}
- "" => DumbFoo { #2
+ "" => DumbFoo { #2
foo: "foo"
"bar": "bar"
}
@@ -90,15 +92,15 @@ public function testGet()
}
"" => {$var['line']}
"" => array:1 [
- => {} #3
+ => {} #3
]
- "" => array:1 [ #4
- => &4 array:1 [@4]
+ "" => array:1 [ #4
+ => &4 array:1 [@4]
]
- => &1 null
- "" => DumbFoo {@2}
- "" => &3 {@3}
- "" => {@3}
+ => &1 null
+ "" => DumbFoo {@2}
+ "" => &3 {@3}
+ "" => {@3}
"" => "{$var['file']}"
b"" => ""
]