Phalcon\Test\Unit\Mvc\View\Engine\Volt\CompilerTest::testVoltSyntaxError PHP Method

testVoltSyntaxError() public method

public testVoltSyntaxError ( )
    public function testVoltSyntaxError()
    {
        $this->specify("Volt parser doesn't throw the proper syntax error", function () {
            $volt = new Compiler();
            $volt->parse('{{');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Syntax error, unexpected EOF in eval code"]]);
        $this->specify("Volt parser doesn't throw the proper syntax error (2)", function () {
            $volt = new Compiler();
            $volt->parse('{{ }}');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Syntax error, unexpected EOF in eval code"]]);
        $this->specify("Volt parser doesn't throw the proper syntax error (3)", function () {
            $volt = new Compiler();
            $volt->parse('{{ ++v }}');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Syntax error, unexpected token ++ in eval code on line 1"]]);
        $this->specify("Volt parser doesn't throw the proper syntax error (4)", function () {
            $volt = new Compiler();
            $volt->parse('{{
                    ++v }}');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Syntax error, unexpected token ++ in eval code on line 2"]]);
        $this->specify("Volt parser doesn't throw the proper syntax error (5)", function () {
            $volt = new Compiler();
            $volt->parse('{{


                    if
                for }}');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Syntax error, unexpected token IF in eval code on line 4"]]);
        $this->specify("Volt parser doesn't throw the proper syntax error (6)", function () {
            $volt = new Compiler();
            $i = $volt->parse('{% block some %}
                    {% for x in y %}
                        {{ ."hello".y }}
                    {% endfor %}
                {% endblock %}');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Syntax error, unexpected token DOT in eval code on line 3"]]);
        $this->specify("Volt parser doesn't throw the proper syntax error (7)", function () {
            $volt = new Compiler();
            $volt->parse('{#

                    This is a multi-line comment

                #}{% block some %}
                    {# This is a single-line comment #}
                    {% for x in y %}
                        {{ "hello"++y }}
                    {% endfor %}
                {% endblock %}');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Syntax error, unexpected token IDENTIFIER(y) in eval code on line 8"]]);
        $this->specify("Volt parser doesn't throw the proper syntax error (8)", function () {
            $volt = new Compiler();
            $volt->parse('{# Hello #}

                {% for robot in robots %}
                    {{ link_to("hello", robot.id ~ ~ robot.name) }}
                {% endfor %}

                ');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, 'Syntax error, unexpected token ~ in eval code on line 4']]);
        $this->specify("Volt parser doesn't throw the proper syntax error (9)", function () {
            $volt = new Compiler();
            $volt->parse('{{ link_to("album/" ~ album.id ~ "/" ~ $album.uri, "<img src=\\"" ~ album.url ~ "\\" alt=\\"" ~ album.name ~ "\\"/>") }}');
        }, ["throws" => [\Phalcon\Mvc\View\Exception::class, "Scanning error before 'album.uri, \"<img...' in eval code on line 1"]]);
    }