Drupal investigation

VarDumperTestCase.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\VarDumper\Test;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\VarDumper\Cloner\VarCloner;
  13. use Symfony\Component\VarDumper\Dumper\CliDumper;
  14. /**
  15. * @author Nicolas Grekas <p@tchwork.com>
  16. *
  17. * @deprecated since version 2.8, to be removed in 3.0. Use the VarDumperTestTrait instead.
  18. */
  19. abstract class VarDumperTestCase extends TestCase
  20. {
  21. public function assertDumpEquals($dump, $data, $message = '')
  22. {
  23. $this->assertSame(rtrim($dump), $this->getDump($data), $message);
  24. }
  25. public function assertDumpMatchesFormat($dump, $data, $message = '')
  26. {
  27. $this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message);
  28. }
  29. protected function getDump($data)
  30. {
  31. $h = fopen('php://memory', 'r+b');
  32. $cloner = new VarCloner();
  33. $dumper = new CliDumper($h);
  34. $dumper->setColors(false);
  35. $dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
  36. $data = stream_get_contents($h, -1, 0);
  37. fclose($h);
  38. return rtrim($data);
  39. }
  40. }