8000 [HttpKernel] DumpDataCollector: do not flush when a dumper is provided · symfony/symfony@11a0392 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11a0392

Browse files
committed
[HttpKernel] DumpDataCollector: do not flush when a dumper is provided
1 parent 2349e97 commit 11a0392

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function dump(Data $data)
6767
if ($this->stopwatch) {
6868
$this->stopwatch->start('dump');
6969
}
70-
if ($this->isCollected) {
70+
if ($this->isCollected && !$this->dumper) {
7171
$this->isCollected = false;
7272
}
7373

src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\VarDumper\Cloner\Data;
19+
use Symfony\Component\VarDumper\Dumper\CliDumper;
1920

2021
/**
2122
* @author Nicolas Grekas <p@tchwork.com>
@@ -130,4 +131,24 @@ public function testFlush()
130131
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean());
131132
}
132133
}
134+
135+
public function testFlushNothingWhenDataDumperIsProvided()
136+
{
137+
$data = new Data(array(array(456)));
138+
$dumper = new CliDumper('php://output');
139+
$collector = new DumpDataCollector(null, null, null, null, $dumper);
140+
141+
ob_start();
142+
$collector->dump($data);
143+
$line = __LINE__ - 1;
144+
if (\PHP_VERSION_ID >= 50400) {
145+
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
146+
} else {
147+
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean());
148+
}
149+
150+
ob_start();
151+
$collector->__destruct();
152+
$this->assertEmpty(ob_get_clean());
153+
}
133154
}

0 commit comments

Comments
 (0)
0