TwigExtractor example

public function testExtract($template$messages)
    {
        $loader = $this->createMock(LoaderInterface::class);
        $twig = new Environment($loader[
            'strict_variables' => true,
            'debug' => true,
            'cache' => false,
            'autoescape' => false,
        ]);
        $twig->addExtension(new TranslationExtension($this->createMock(TranslatorInterface::class)));

        $extractor = new TwigExtractor($twig);
        $extractor->setPrefix('prefix');
        $catalogue = new MessageCatalogue('en');

        $m = new \ReflectionMethod($extractor, 'extractTemplate');
        $m->invoke($extractor$template$catalogue);

        if (0 === \count($messages)) {
            $this->assertSame($catalogue->all()$messages);
        }

        foreach ($messages as $key => $domain) {
            
Home | Imprint | This part of the site doesn't use cookies.