Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/var-dumper/Test/VarDumperTestTrait.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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\Test; | |
13 | |
14 use Symfony\Component\VarDumper\Cloner\VarCloner; | |
15 use Symfony\Component\VarDumper\Dumper\CliDumper; | |
16 | |
17 /** | |
18 * @author Nicolas Grekas <p@tchwork.com> | |
19 */ | |
20 trait VarDumperTestTrait | |
21 { | |
22 public function assertDumpEquals($dump, $data, $message = '') | |
23 { | |
24 $this->assertSame(rtrim($dump), $this->getDump($data), $message); | |
25 } | |
26 | |
27 public function assertDumpMatchesFormat($dump, $data, $message = '') | |
28 { | |
29 $this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message); | |
30 } | |
31 | |
32 protected function getDump($data, $key = null) | |
33 { | |
34 $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0; | |
35 $flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0; | |
36 | |
37 $cloner = new VarCloner(); | |
38 $cloner->setMaxItems(-1); | |
39 $dumper = new CliDumper(null, null, $flags); | |
40 $dumper->setColors(false); | |
41 $data = $cloner->cloneVar($data)->withRefHandles(false); | |
42 if (null !== $key && null === $data = $data->seek($key)) { | |
43 return; | |
44 } | |
45 | |
46 return rtrim($dumper->dump($data, true)); | |
47 } | |
48 } |