Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / http-kernel / Tests / DataCollector / DataCollectorTest.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\HttpKernel\Tests\DataCollector;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpFoundation\Request;
16 use Symfony\Component\HttpFoundation\Response;
17 use Symfony\Component\HttpKernel\Tests\Fixtures\DataCollector\CloneVarDataCollector;
18 use Symfony\Component\VarDumper\Cloner\Stub;
19 use Symfony\Component\VarDumper\Cloner\VarCloner;
20 use Symfony\Component\VarDumper\Dumper\CliDumper;
21
22 class DataCollectorTest extends TestCase
23 {
24     public function testCloneVarStringWithScheme()
25     {
26         $c = new CloneVarDataCollector('scheme://foo');
27         $c->collect(new Request(), new Response());
28         $cloner = new VarCloner();
29
30         $this->assertEquals($cloner->cloneVar('scheme://foo'), $c->getData());
31     }
32
33     public function testCloneVarExistingFilePath()
34     {
35         $c = new CloneVarDataCollector($filePath = tempnam(sys_get_temp_dir(), 'clone_var_data_collector_'));
36         $c->collect(new Request(), new Response());
37
38         $data = $c->getData();
39         $this->assertInstanceOf(Stub::class, $data->getRawData()[0][0]);
40         $this->assertDumpEquals("\"$filePath\"", $data);
41     }
42
43     private function assertDumpEquals($dump, $data, $message = '')
44     {
45         $dumper = new CliDumper();
46         $dumper->setColors(false);
47
48         $this->assertSame(rtrim($dump), rtrim($dumper->dump($data, true)), $message);
49     }
50 }