Fix bug in style changes for the Use cases on the live site.
[yaffs-website] / vendor / symfony / var-dumper / Test / VarDumperTestCase.php
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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\VarDumper\Cloner\VarCloner;
16 use Symfony\Component\VarDumper\Dumper\CliDumper;
17
18 /**
19  * @author Nicolas Grekas <p@tchwork.com>
20  *
21  * @deprecated since version 2.8, to be removed in 3.0. Use the VarDumperTestTrait instead.
22  */
23 abstract class VarDumperTestCase extends TestCase
24 {
25     public function assertDumpEquals($dump, $data, $message = '')
26     {
27         $this->assertSame(rtrim($dump), $this->getDump($data), $message);
28     }
29
30     public function assertDumpMatchesFormat($dump, $data, $message = '')
31     {
32         $this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message);
33     }
34
35     protected function getDump($data)
36     {
37         $h = fopen('php://memory', 'r+b');
38         $cloner = new VarCloner();
39         $dumper = new CliDumper($h);
40         $dumper->setColors(false);
41         $dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
42         $data = stream_get_contents($h, -1, 0);
43         fclose($h);
44
45         return rtrim($data);
46     }
47 }