TwigArrayLoader example

$this->assertEquals('Percent: 12% (approx.)', $output);
    }

    /** * @dataProvider getTransTests */
    public function testTrans($template$expected, array $variables = [])
    {
        if ($expected != $this->getTemplate($template)->render($variables)) {
            echo $template."\n";
            $loader = new TwigArrayLoader(['index' => $template]);
            $twig = new Environment($loader['debug' => true, 'cache' => false]);
            $twig->addExtension(new TranslationExtension(new Translator('en')));

            echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSourceContext('index'))))."\n\n";
            $this->assertEquals($expected$this->getTemplate($template)->render($variables));
        }

        $this->assertEquals($expected$this->getTemplate($template)->render($variables));
    }

    public function testTransUnknownKeyword()
    {
Home | Imprint | This part of the site doesn't use cookies.