8000 bug #15866 [VarDumper] Fix dump comparison on large arrays (romainneu… · symfony/symfony@507e959 · GitHub
[go: up one dir, main page]

Skip to content

Commit 507e959

Browse files
committed
bug #15866 [VarDumper] Fix dump comparison on large arrays (romainneutron)
This PR was merged into the 2.7 branch. Discussion ---------- [VarDumper] Fix dump comparison on large arrays | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT Commits ------- 6a6e7f3 [VarDumper] Fix dump comparison on large arrays
2 parents 8eda312 + 6a6e7f3 commit 507e959

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ private function getVarDumperDump($data)
3333
{
3434
$h = fopen('php://memory', 'r+b');
3535
$cloner = new VarCloner();
36+
$cloner->setMaxItems(-1);
3637
$dumper = new CliDumper($h);
3738
$dumper->setColors(false);
3839
$dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\VarDumper\Tests\Test;
13+
14+
use Symfony\Component\VarDumper\Test\VarDumperTestCase;
15+
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
16+
17+
class VarDumperTestTraitTest extends VarDumperTestCase
18+
{
19+
use VarDumperTestTrait;
20+
21+
public function testItComparesLargeData()
22+
{
23+
$howMany = 700;
24+
$data = array_fill_keys(range(0, $howMany), array('a', 'b', 'c', 'd'));
25+
26+
$expected = sprintf("array:%d [\n", $howMany + 1);
27+
for ($i = 0; $i <= $howMany; ++$i) {
28+
$expected .= <<<EODUMP
29+
$i => array:4 [
30+
0 => "a"
31+
1 => "b"
32+
2 => "c"
33+
3 => "d"
34+
]\n
35+
EODUMP;
36+
}
37+
$expected .= "]\n";
38+
39+
$this->assertDumpEquals($expected, $data);
40+
}
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
// Skipping trait tests for PHP < 5.4
13+
if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) {
14+
require 'VarDumpTestTraitRequire54.php';
15+
}
16+

0 commit comments

Comments
 (0)
0