TestVarDumper.php in Drupal 9
File
core/tests/Drupal/TestTools/TestVarDumper.php
View source
<?php
namespace Drupal\TestTools;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
class TestVarDumper {
public static function cliHandler($var) {
$cloner = new VarCloner();
$dumper = new CliDumper();
fwrite(STDOUT, "\n");
$dumper
->setColors(TRUE);
$dumper
->dump($cloner
->cloneVar($var), function ($line, $depth, $indent_pad) {
if ($depth >= 0) {
fwrite(STDOUT, str_repeat($indent_pad, $depth) . $line . "\n");
}
});
}
public static function htmlHandler($var) {
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper
->dump($cloner
->cloneVar($var));
}
}
Classes
Name |
Description |
TestVarDumper |
Provides handlers for the Symfony VarDumper to work within tests. |