summaryrefslogtreecommitdiffstats
path: root/tests/Utils/ErrorTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Utils/ErrorTest.php')
-rw-r--r--tests/Utils/ErrorTest.php34
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)))
+ );
+ }
+}