summaryrefslogtreecommitdiffstats
path: root/tests/Utils/ErrorTest.php
blob: 8408194c7b70005c1b927cc2d397eea76aae0fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

namespace SqlParser\Tests\Utils;

use SqlParser\Lexer;
use SqlParser\Parser;
use SqlParser\Utils\Error;
use SqlParser\Tests\TestCase;

class ErrorTest extends TestCase
{
    public function testGet()
    {
        $lexer = new Lexer('SELECT * FROM db..tbl $');
        $parser = new Parser($lexer->list);
        $this->assertEquals(
            array(
                array('Unexpected character.', 0, '$', 22),
                array('Unexpected dot.', 0, '.', 17),
            ),
            Error::get(array($lexer, $parser))
        );
    }

    public function testFormat()
    {
        $this->assertEquals(
            array('#1: error msg (near "token" at position 100)'),
            Error::format(array(array('error msg', 42, 'token', 100)))
        );
    }
}