comparison vendor/symfony/var-dumper/Test/VarDumperTestTrait.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
17 /** 17 /**
18 * @author Nicolas Grekas <p@tchwork.com> 18 * @author Nicolas Grekas <p@tchwork.com>
19 */ 19 */
20 trait VarDumperTestTrait 20 trait VarDumperTestTrait
21 { 21 {
22 public function assertDumpEquals($dump, $data, $message = '') 22 public function assertDumpEquals($dump, $data, $filter = 0, $message = '')
23 { 23 {
24 $this->assertSame(rtrim($dump), $this->getDump($data), $message); 24 if (is_string($filter)) {
25 @trigger_error(sprintf('The $message argument of the "%s()" method at 3rd position is deprecated since Symfony 3.4 and will be moved at 4th position in 4.0.', __METHOD__), E_USER_DEPRECATED);
26 $message = $filter;
27 $filter = 0;
28 }
29
30 $this->assertSame(rtrim($dump), $this->getDump($data, null, $filter), $message);
25 } 31 }
26 32
27 public function assertDumpMatchesFormat($dump, $data, $message = '') 33 public function assertDumpMatchesFormat($dump, $data, $filter = 0, $message = '')
28 { 34 {
29 $this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message); 35 if (is_string($filter)) {
36 @trigger_error(sprintf('The $message argument of the "%s()" method at 3rd position is deprecated since Symfony 3.4 and will be moved at 4th position in 4.0.', __METHOD__), E_USER_DEPRECATED);
37 $message = $filter;
38 $filter = 0;
39 }
40
41 $this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data, null, $filter), $message);
30 } 42 }
31 43
32 protected function getDump($data, $key = null) 44 protected function getDump($data, $key = null, $filter = 0)
33 { 45 {
34 $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0; 46 $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;
35 $flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0; 47 $flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0;
36 48
37 $cloner = new VarCloner(); 49 $cloner = new VarCloner();
38 $cloner->setMaxItems(-1); 50 $cloner->setMaxItems(-1);
39 $dumper = new CliDumper(null, null, $flags); 51 $dumper = new CliDumper(null, null, $flags);
40 $dumper->setColors(false); 52 $dumper->setColors(false);
41 $data = $cloner->cloneVar($data)->withRefHandles(false); 53 $data = $cloner->cloneVar($data, $filter)->withRefHandles(false);
42 if (null !== $key && null === $data = $data->seek($key)) { 54 if (null !== $key && null === $data = $data->seek($key)) {
43 return; 55 return;
44 } 56 }
45 57
46 return rtrim($dumper->dump($data, true)); 58 return rtrim($dumper->dump($data, true));