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
This commit is contained in:
commit
507e959e37
@ -33,6 +33,7 @@ trait VarDumperTestTrait
|
||||
{
|
||||
$h = fopen('php://memory', 'r+b');
|
||||
$cloner = new VarCloner();
|
||||
$cloner->setMaxItems(-1);
|
||||
$dumper = new CliDumper($h);
|
||||
$dumper->setColors(false);
|
||||
$dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
|
||||
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Test;
|
||||
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestCase;
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
|
||||
class VarDumperTestTraitTest extends VarDumperTestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
public function testItComparesLargeData()
|
||||
{
|
||||
$howMany = 700;
|
||||
$data = array_fill_keys(range(0, $howMany), array('a', 'b', 'c', 'd'));
|
||||
|
||||
$expected = sprintf("array:%d [\n", $howMany + 1);
|
||||
for ($i = 0; $i <= $howMany; ++$i) {
|
||||
$expected .= <<<EODUMP
|
||||
$i => array:4 [
|
||||
0 => "a"
|
||||
1 => "b"
|
||||
2 => "c"
|
||||
3 => "d"
|
||||
]\n
|
||||
EODUMP;
|
||||
}
|
||||
$expected .= "]\n";
|
||||
|
||||
$this->assertDumpEquals($expected, $data);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
// Skipping trait tests for PHP < 5.4
|
||||
if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) {
|
||||
require 'VarDumpTestTraitRequire54.php';
|
||||
}
|
||||
|
Reference in New Issue
Block a user