assertNodeCompilation example

use Twig\Node\Node;

abstract class NodeTestCase extends TestCase
{
    abstract public function getTests();

    /** * @dataProvider getTests */
    public function testCompile($node$source$environment = null, $isPattern = false)
    {
        $this->assertNodeCompilation($source$node$environment$isPattern);
    }

    public function assertNodeCompilation($source, Node $node, Environment $environment = null, $isPattern = false)
    {
        $compiler = $this->getCompiler($environment);
        $compiler->compile($node);

        if ($isPattern) {
            $this->assertStringMatchesFormat($sourcetrim($compiler->getSource()));
        } else {
            $this->assertEquals($sourcetrim($compiler->getSource()));
        }
Home | Imprint | This part of the site doesn't use cookies.