diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-07-15 00:19:14 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-07-15 00:19:14 +0300 |
commit | d8c6b9cc361a610ef04df9d86b61aabbb68eacb3 (patch) | |
tree | d9e6ab71497b777fc58fc1715315e56ccd934684 /tests/Components/Array2dTest.php | |
parent | 380603a8bfebd612bbc70801d99eb727be3e36ce (diff) | |
download | sql-parser-d8c6b9cc361a610ef04df9d86b61aabbb68eacb3.zip sql-parser-d8c6b9cc361a610ef04df9d86b61aabbb68eacb3.tar.gz sql-parser-d8c6b9cc361a610ef04df9d86b61aabbb68eacb3.tar.bz2 |
Improved error messages.
Achieved 100% code coverage.
Some refactoring.
Diffstat (limited to 'tests/Components/Array2dTest.php')
-rw-r--r-- | tests/Components/Array2dTest.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/Components/Array2dTest.php b/tests/Components/Array2dTest.php new file mode 100644 index 0000000..5ec9d7e --- /dev/null +++ b/tests/Components/Array2dTest.php @@ -0,0 +1,64 @@ +<?php + +namespace SqlParser\Tests\Components; + +use SqlParser\Parser; +use SqlParser\Components\Array2d; + +use SqlParser\Tests\TestCase; + +class Array2dTest extends TestCase +{ + + public function testParse() + { + $parser = new Parser(); + $arrays = Array2d::parse($parser, $this->getTokensList('(1, 2) +')); + $this->assertEquals( + array(1, 2), + $arrays[0]->values + ); + } + + public function testParseErr1() + { + $parser = new Parser(); + Array2d::parse($parser, $this->getTokensList('(1, 2 +')); + // TODO: Assert errors. + } + + public function testParseErr2() + { + $parser = new Parser(); + Array2d::parse($parser, $this->getTokensList('(1, 2 TABLE')); + } + + public function testParseErr3() + { + $parser = new Parser(); + Array2d::parse($parser, $this->getTokensList(')')); + Array2d::parse($parser, $this->getTokensList('TABLE')); + // TODO: Assert errors. + } + + public function testParseErr4() + { + $parser = new Parser(); + Array2d::parse($parser, $this->getTokensList('(1, 2),')); + $this->assertEquals( + "Expected open bracket followed by a set of values.", + $parser->errors[0]->getMessage() + ); + } + + public function testParseErr5() + { + $parser = new Parser(); + Array2d::parse($parser, $this->getTokensList('(1, 2),(3)')); + $this->assertEquals( + "Expected 2 values, found 1.", + $parser->errors[0]->getMessage() + ); + } + +} |