NullDumper example

$container = new ContainerBuilder();
        $container->register('foo', 'stdClass')->addArgument(new Reference('bar'))->setPublic(true);
        $container->register('bar', 'stdClass')->setLazy(true)->addArgument(new Reference('foo'))->setPublic(true);
        $container->compile();

        $dumper = new PhpDumper($container);
        $dumper->dump();

        $this->addToAssertionCount(1);

        $dumper = new PhpDumper($container);
        $dumper->setProxyDumper(new NullDumper());

        $message = 'Circular reference detected for service "foo", path: "foo -> bar -> foo".';
        $this->expectException(ServiceCircularReferenceException::class);
        $this->expectExceptionMessage($message);

        $dumper->dump();
    }

    public function testDedupLazyProxy()
    {
        $container = new ContainerBuilder();
        
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;

/** * Tests for {@see \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper}. * * @author Marco Pivetta <ocramius@gmail.com> */
class NullDumperTest extends TestCase
{
    public function testNullDumper()
    {
        $dumper = new NullDumper();
        $definition = new Definition('stdClass');

        $this->assertFalse($dumper->isProxyCandidate($definition));
        $this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo', '(false)'));
        $this->assertSame('', $dumper->getProxyCode($definition));
    }
}
Home | Imprint | This part of the site doesn't use cookies.