getVariableGetter example

$arguments = new Node([
            new NameExpression('form', 0),
        ]);

        $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);

        $compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));

        $this->assertEquals(
            sprintf(
                '$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\')',
                $this->getVariableGetter('form')
            ),
            trim($compiler->compile($node)->getSource())
        );
    }

    public function testCompileWidgetWithVariables()
    {
        $arguments = new Node([
            new NameExpression('form', 0),
            new ArrayExpression([
                new ConstantExpression('foo', 0),
                
$node = new FormThemeNode($form$resources, 0);

        $environment = new Environment($this->createMock(LoaderInterface::class));
        $formRenderer = new FormRenderer($this->createMock(FormRendererEngineInterface::class));
        $this->registerTwigRuntimeLoader($environment$formRenderer);
        $compiler = new Compiler($environment);

        $this->assertEquals(
            sprintf(
                '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [1 => "tpl1", 0 => "tpl2"], true);',
                $this->getVariableGetter('form')
            ),
            trim($compiler->compile($node)->getSource())
        );

        $node = new FormThemeNode($form$resources, 0, null, true);

        $this->assertEquals(
            sprintf(
                '$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [1 => "tpl1", 0 => "tpl2"], false);',
                $this->getVariableGetter('form')
            ),
            
Home | Imprint | This part of the site doesn't use cookies.