class DumpDataCollectorTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php \Symfony\Component\HttpKernel\Tests\DataCollector\DumpDataCollectorTest
@author Nicolas Grekas <p@tchwork.com>
Hierarchy
- class \Symfony\Component\HttpKernel\Tests\DataCollector\DumpDataCollectorTest extends \Symfony\Component\HttpKernel\Tests\DataCollector\PHPUnit_Framework_TestCase
Expanded class hierarchy of DumpDataCollectorTest
File
- vendor/
symfony/ http-kernel/ Tests/ DataCollector/ DumpDataCollectorTest.php, line 22
Namespace
Symfony\Component\HttpKernel\Tests\DataCollectorView source
class DumpDataCollectorTest extends \PHPUnit_Framework_TestCase {
public function testDump() {
$data = new Data(array(
array(
123,
),
));
$collector = new DumpDataCollector();
$this
->assertSame('dump', $collector
->getName());
$collector
->dump($data);
$line = __LINE__ - 1;
$this
->assertSame(1, $collector
->getDumpsCount());
$dump = $collector
->getDumps('html');
$this
->assertTrue(isset($dump[0]['data']));
$dump[0]['data'] = preg_replace('/^.*?<pre/', '<pre', $dump[0]['data']);
$dump[0]['data'] = preg_replace('/sf-dump-\\d+/', 'sf-dump', $dump[0]['data']);
$xDump = array(
array(
'data' => "<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-num>123</span>\n</pre><script>Sfdump(\"sf-dump\")</script>\n",
'name' => 'DumpDataCollectorTest.php',
'file' => __FILE__,
'line' => $line,
'fileExcerpt' => false,
),
);
$this
->assertSame($xDump, $dump);
$this
->assertStringMatchesFormat('a:1:{i:0;a:5:{s:4:"data";O:39:"Symfony\\Component\\VarDumper\\Cloner\\Data":4:{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:%i;s:57:"Symfony\\Component\\VarDumper\\Cloner\\DatamaxItemsPerDepth";i:%i;s:54:"Symfony\\Component\\VarDumper\\Cloner\\DatauseRefHandles";i:%i;}s:4:"name";s:25:"DumpDataCollectorTest.php";s:4:"file";s:%a', str_replace("\0", '', $collector
->serialize()));
$this
->assertSame(0, $collector
->getDumpsCount());
$this
->assertSame('a:0:{}', $collector
->serialize());
}
public function testCollectDefault() {
$data = new Data(array(
array(
123,
),
));
$collector = new DumpDataCollector();
$collector
->dump($data);
$line = __LINE__ - 1;
ob_start();
$collector
->collect(new Request(), new Response());
$output = ob_get_clean();
if (PHP_VERSION_ID >= 50400) {
$this
->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
}
else {
$this
->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n123\n", $output);
}
$this
->assertSame(1, $collector
->getDumpsCount());
$collector
->serialize();
}
public function testCollectHtml() {
$data = new Data(array(
array(
123,
),
));
$collector = new DumpDataCollector(null, 'test://%f:%l');
$collector
->dump($data);
$line = __LINE__ - 1;
$file = __FILE__;
if (PHP_VERSION_ID >= 50400) {
$xOutput = <<<EOTXT
<pre class=sf-dump id=sf-dump data-indent-pad=" "><a href="test://{<span class="php-variable">$file</span>}:{<span class="php-variable">$line</span>}" title="{<span class="php-variable">$file</span>}"><span class=sf-dump-meta>DumpDataCollectorTest.php</span></a> on line <span class=sf-dump-meta>{<span class="php-variable">$line</span>}</span>:
<span class=sf-dump-num>123</span>
</pre>
EOTXT;
}
else {
$len = strlen("DumpDataCollectorTest.php on line {$line}:");
$xOutput = <<<EOTXT
<pre class=sf-dump id=sf-dump data-indent-pad=" ">"<span class=sf-dump-str title="{<span class="php-variable">$len</span>} characters">DumpDataCollectorTest.php on line {<span class="php-variable">$line</span>}:</span>"
</pre>
<pre class=sf-dump id=sf-dump data-indent-pad=" "><span class=sf-dump-num>123</span>
</pre>
EOTXT;
}
ob_start();
$response = new Response();
$response->headers
->set('Content-Type', 'text/html');
$collector
->collect(new Request(), $response);
$output = ob_get_clean();
$output = preg_replace('#<(script|style).*?</\\1>#s', '', $output);
$output = preg_replace('/sf-dump-\\d+/', 'sf-dump', $output);
$this
->assertSame($xOutput, $output);
$this
->assertSame(1, $collector
->getDumpsCount());
$collector
->serialize();
}
public function testFlush() {
$data = new Data(array(
array(
456,
),
));
$collector = new DumpDataCollector();
$collector
->dump($data);
$line = __LINE__ - 1;
ob_start();
$collector = null;
if (PHP_VERSION_ID >= 50400) {
$this
->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
}
else {
$this
->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean());
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DumpDataCollectorTest:: |
public | function | ||
DumpDataCollectorTest:: |
public | function | ||
DumpDataCollectorTest:: |
public | function | ||
DumpDataCollectorTest:: |
public | function |