diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-07-09 00:50:28 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-07-09 00:50:28 +0300 |
commit | 9478c9a1d7eae3283bc5aae248d9d23b4a9f7bc6 (patch) | |
tree | c1f22f43adda2376fbd0a5638e57426b4d6009bd /tests/Utils/ErrorTest.php | |
parent | 0bff48ae488e651c37d84ba0a9aa8ff57ae8a43e (diff) | |
download | sql-parser-9478c9a1d7eae3283bc5aae248d9d23b4a9f7bc6.zip sql-parser-9478c9a1d7eae3283bc5aae248d9d23b4a9f7bc6.tar.gz sql-parser-9478c9a1d7eae3283bc5aae248d9d23b4a9f7bc6.tar.bz2 |
Added utilities for parsing errors.
Diffstat (limited to 'tests/Utils/ErrorTest.php')
-rw-r--r-- | tests/Utils/ErrorTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/Utils/ErrorTest.php b/tests/Utils/ErrorTest.php new file mode 100644 index 0000000..25e65f4 --- /dev/null +++ b/tests/Utils/ErrorTest.php @@ -0,0 +1,34 @@ +<?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))) + ); + } +} |