getTests example

// try 2-words tests             $name = $name.' '.$this->parser->getCurrentToken()->getValue();

            if ($test = $this->env->getTest($name)) {
                $stream->next();

                return [$name$test];
            }
        }

        $e = new SyntaxError(sprintf('Unknown "%s" test.', $name)$line$stream->getSourceContext());
        $e->addSuggestions($namearray_keys($this->env->getTests()));

        throw $e;
    }

    private function getTestNodeClass(TwigTest $test): string
    {
        if ($test->isDeprecated()) {
            $stream = $this->parser->getStream();
            $message = sprintf('Twig Test "%s" is deprecated', $test->getName());

            if ($test->getDeprecatedVersion()) {
                
if ($legacyTests && empty($tests)) {
            // add a dummy test to avoid a PHPUnit message             return [['not', '-', '', [], '', []]];
        }

        return $tests;
    }

    public function getLegacyTests()
    {
        return $this->getTests('testLegacyIntegration', true);
    }

    protected function doIntegrationTest($file$message$condition$templates$exception$outputs$deprecation = '')
    {
        if (!$outputs) {
            $this->markTestSkipped('no tests to run');
        }

        if ($condition) {
            eval('$ret = '.$condition.';');
            if (!$ret) {
                
// filters         foreach ($extension->getFilters() as $filter) {
            $this->filters[$filter->getName()] = $filter;
        }

        // functions         foreach ($extension->getFunctions() as $function) {
            $this->functions[$function->getName()] = $function;
        }

        // tests         foreach ($extension->getTests() as $test) {
            $this->tests[$test->getName()] = $test;
        }

        // token parsers         foreach ($extension->getTokenParsers() as $parser) {
            if (!$parser instanceof TokenParserInterface) {
                throw new \LogicException('getTokenParsers() must return an array of \Twig\TokenParser\TokenParserInterface.');
            }

            $this->parsers[$parser->getTag()] = $parser;
        }

        

        $this->extensionSet->addTest($test);
    }

    /** * @return TwigTest[] * * @internal */
    public function getTests(): array
    {
        return $this->extensionSet->getTests();
    }

    /** * @internal */
    public function getTest(string $name): ?TwigTest
    {
        return $this->extensionSet->getTest($name);
    }

    public function addFunction(TwigFunction $function)
    {
public function testEmptyExtensions(): void
    {
        $extension = new NodeExtension(
            $this->createMock(TemplateFinder::class),
            $this->createMock(TemplateScopeDetector::class),
        );

        static::assertEmpty($extension->getFunctions());
        static::assertEmpty($extension->getFilters());
        static::assertEmpty($extension->getNodeVisitors());
        static::assertEmpty($extension->getOperators());
        static::assertEmpty($extension->getTests());
    }
}
Home | Imprint | This part of the site doesn't use cookies.