4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\VarDumper\Test;
14 use Symfony\Component\VarDumper\Cloner\VarCloner;
15 use Symfony\Component\VarDumper\Dumper\CliDumper;
18 * @author Nicolas Grekas <p@tchwork.com>
20 trait VarDumperTestTrait
22 public function assertDumpEquals($dump, $data, $message = '')
24 $this->assertSame(rtrim($dump), $this->getDump($data), $message);
27 public function assertDumpMatchesFormat($dump, $data, $message = '')
29 $this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message);
32 protected function getDump($data)
34 $h = fopen('php://memory', 'r+b');
35 $cloner = new VarCloner();
36 $cloner->setMaxItems(-1);
37 $dumper = new CliDumper($h);
38 $dumper->setColors(false);
39 $dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
40 $data = stream_get_contents($h, -1, 0);