4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests\DataCollector;
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;
22 class DataCollectorTest extends TestCase
24 public function testCloneVarStringWithScheme()
26 $c = new CloneVarDataCollector('scheme://foo');
27 $c->collect(new Request(), new Response());
28 $cloner = new VarCloner();
30 $this->assertEquals($cloner->cloneVar('scheme://foo'), $c->getData());
33 public function testCloneVarExistingFilePath()
35 $c = new CloneVarDataCollector($filePath = tempnam(sys_get_temp_dir(), 'clone_var_data_collector_'));
36 $c->collect(new Request(), new Response());
38 $data = $c->getData();
39 $this->assertInstanceOf(Stub::class, $data->getRawData()[0][0]);
40 $this->assertDumpEquals("\"$filePath\"", $data);
43 private function assertDumpEquals($dump, $data, $message = '')
45 $dumper = new CliDumper();
46 $dumper->setColors(false);
48 $this->assertSame(rtrim($dump), rtrim($dumper->dump($data, true)), $message);