diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Lexer/ContextTest.php | 2 | ||||
-rw-r--r-- | tests/Utils/ErrorTest.php | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/Lexer/ContextTest.php b/tests/Lexer/ContextTest.php index 50e500a..dca3dec 100644 --- a/tests/Lexer/ContextTest.php +++ b/tests/Lexer/ContextTest.php @@ -30,7 +30,7 @@ class ContextTest extends TestCase /** * @expectedException Exception - * @expectedExceptionMessage Specified context ("\SqlParser\Contexts\ContextFoo") doesn't exist. + * @expectedExceptionMessage Specified context ("\SqlParser\Contexts\ContextFoo") does not exist. */ public function testLoadError() { 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))) + ); + } +} |