|
15 | 15 | use Symfony\Bundle\DebugBundle\DependencyInjection\DebugExtension;
|
16 | 16 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 | 17 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
| 18 | +use Symfony\Component\HttpFoundation\RequestStack; |
18 | 19 | use Symfony\Component\VarDumper\Caster\ReflectionCaster;
|
| 20 | +use Symfony\Component\VarDumper\Dumper\CliDumper; |
| 21 | +use Symfony\Component\VarDumper\Server\Connection; |
| 22 | +use Symfony\Component\VarDumper\Server\DumpServer; |
19 | 23 |
|
20 | 24 | class DebugExtensionTest extends TestCase
|
21 | 25 | {
|
@@ -70,12 +74,49 @@ public function testUnsetClosureFileInfoShouldBeRegisteredInVarCloner()
|
70 | 74 | $this->assertTrue($called);
|
71 | 75 | }
|
72 | 76 |
|
| 77 | + public function provideServicesUsingDumpDestinationCreation(): array |
| 78 | + { |
| 79 | + return [ |
| 80 | + ['tcp://localhost:1234', 'tcp://localhost:1234', null], |
| 81 | + [null, '', null], |
| 82 | + ['php://stderr', '', 'php://stderr'], |
| 83 | + ]; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * @dataProvider provideServicesUsingDumpDestinationCreation |
| 88 | + */ |
| 89 | + public function testServicesUsingDumpDestinationCreation(?string $dumpDestination, string $expectedHost, ?string $expectedOutput) |
| 90 | + { |
| 91 | + $container = $this->createContainer(); |
| 92 | + $container->registerExtension(new DebugExtension()); |
| 93 | + $container->loadFromExtension('debug', ['dump_destination' => $dumpDestination]); |
| 94 | + $container->setAlias('dump_server_public', 'var_dumper.dump_server')->setPublic(true); |
| 95 | + $container->setAlias('server_conn_public', 'var_dumper.server_connection')->setPublic(true); |
| 96 | + $container->setAlias('cli_dumper_public', 'var_dumper.cli_dumper')->setPublic(true); |
| 97 | + $container->register('request_stack', RequestStack::class); |
| 98 | + $this->compileContainer($container); |
| 99 | + |
| 100 | + $dumpServer = $container->get('dump_server_public'); |
| 101 | + $this->assertInstanceOf(DumpServer::class, $dumpServer); |
| 102 | + $this->assertSame($expectedHost, $container->findDefinition('dump_server_public')->getArgument(0)); |
| 103 | + |
| 104 | + $serverConn = $container->get('server_conn_public'); |
| 105 | + $this->assertInstanceOf(Connection::class, $serverConn); |
| 106 | + $this->assertSame($expectedHost, $container->findDefinition('server_conn_public')->getArgument(0)); |
| 107 | + |
| 108 | + $cliDumper = $container->get('cli_dumper_public'); |
| 109 | + $this->assertInstanceOf(CliDumper::class, $cliDumper); |
| 110 | + $this->assertSame($expectedOutput, $container->findDefinition('cli_dumper_public')->getArgument(0)); |
| 111 | + } |
| 112 | + |
73 | 113 | private function createContainer()
|
74 | 114 | {
|
75 | 115 | $container = new ContainerBuilder(new ParameterBag([
|
76 | 116 | 'kernel.cache_dir' => __DIR__,
|
77 | 117 | 'kernel.charset' => 'UTF-8',
|
78 | 118 | 'kernel.debug' => true,
|
| 119 | + 'kernel.project_dir' => __DIR__, |
79 | 120 | 'kernel.bundles' => ['DebugBundle' => 'Symfony\\Bundle\\DebugBundle\\DebugBundle'],
|
80 | 121 | ]));
|
81 | 122 |
|
|
0 commit comments