StopwatchExtension example


        $this->expectException(\Twig\Error\SyntaxError::class);
        $this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', []);
    }

    /** * @dataProvider getTimingTemplates */
    public function testTiming($template$events)
    {
        $twig = new Environment(new ArrayLoader(['template' => $template])['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]);
        $twig->addExtension(new StopwatchExtension($this->getStopwatch($events)));

        try {
            $twig->render('template');
        } catch (RuntimeError $e) {
            throw $e->getPrevious();
        }
    }

    public static function getTimingTemplates()
    {
        return [
            [
Home | Imprint | This part of the site doesn't use cookies.