updated backend

This commit is contained in:
Torsten 2020-01-17 10:58:01 +01:00
parent 1fea0f4fe7
commit 11521c2339
3459 changed files with 72735 additions and 168535 deletions

View file

@ -19,42 +19,69 @@ use Symfony\Component\VarDumper\Dumper\CliDumper;
*/
trait VarDumperTestTrait
{
public function assertDumpEquals($dump, $data, $filter = 0, $message = '')
{
if (\is_string($filter)) {
@trigger_error(sprintf('The $message argument of the "%s()" method at the 3rd position is deprecated since Symfony 3.4 and will be moved at the 4th position in 4.0.', __METHOD__), E_USER_DEPRECATED);
$message = $filter;
$filter = 0;
}
/**
* @internal
*/
private $varDumperConfig = [
'casters' => [],
'flags' => null,
];
$this->assertSame(rtrim($dump), $this->getDump($data, null, $filter), $message);
protected function setUpVarDumper(array $casters, int $flags = null): void
{
$this->varDumperConfig['casters'] = $casters;
$this->varDumperConfig['flags'] = $flags;
}
public function assertDumpMatchesFormat($dump, $data, $filter = 0, $message = '')
/**
* @after
*/
protected function tearDownVarDumper(): void
{
if (\is_string($filter)) {
@trigger_error(sprintf('The $message argument of the "%s()" method at the 3rd position is deprecated since Symfony 3.4 and will be moved at the 4th position in 4.0.', __METHOD__), E_USER_DEPRECATED);
$message = $filter;
$filter = 0;
}
$this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data, null, $filter), $message);
$this->varDumperConfig['casters'] = [];
$this->varDumperConfig['flags'] = null;
}
public function assertDumpEquals($expected, $data, $filter = 0, $message = '')
{
$this->assertSame($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message);
}
public function assertDumpMatchesFormat($expected, $data, $filter = 0, $message = '')
{
$this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message);
}
/**
* @return string|null
*/
protected function getDump($data, $key = null, $filter = 0)
{
$flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;
$flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0;
if (null === $flags = $this->varDumperConfig['flags']) {
$flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;
$flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0;
$flags |= getenv('DUMP_COMMA_SEPARATOR') ? CliDumper::DUMP_COMMA_SEPARATOR : 0;
}
$cloner = new VarCloner();
$cloner->addCasters($this->varDumperConfig['casters']);
$cloner->setMaxItems(-1);
$dumper = new CliDumper(null, null, $flags);
$dumper->setColors(false);
$data = $cloner->cloneVar($data, $filter)->withRefHandles(false);
if (null !== $key && null === $data = $data->seek($key)) {
return;
return null;
}
return rtrim($dumper->dump($data, true));
}
private function prepareExpectation($expected, int $filter): string
{
if (!\is_string($expected)) {
$expected = $this->getDump($expected, null, $filter);
}
return rtrim($expected);
}
}