diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-08-16 02:48:03 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-08-16 02:48:03 +0300 |
commit | 2c1124c25a74191f4c3bf095238a0a732bfd8a9e (patch) | |
tree | 30ca07e0d1b37a0a567d6be5fabe9bffe2d8a594 /tests/Components | |
parent | 3cbebbe741f4bab1ce4790daa34d4cdd8bf36a25 (diff) | |
download | sql-parser-2c1124c25a74191f4c3bf095238a0a732bfd8a9e.zip sql-parser-2c1124c25a74191f4c3bf095238a0a732bfd8a9e.tar.gz sql-parser-2c1124c25a74191f4c3bf095238a0a732bfd8a9e.tar.bz2 |
Fixed a couple of minor bugs in partition parsing.
'MAXVALUE' can be used for partitions.
The correct class is used for parsing.
Options may be specified for the class that is used for parsing.
Wrote tests.
Diffstat (limited to 'tests/Components')
-rw-r--r-- | tests/Components/ArrayObjTest.php | 17 | ||||
-rw-r--r-- | tests/Components/PartitionDefinitionTest.php | 24 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/Components/ArrayObjTest.php b/tests/Components/ArrayObjTest.php index 13be866..00321ed 100644 --- a/tests/Components/ArrayObjTest.php +++ b/tests/Components/ArrayObjTest.php @@ -2,6 +2,7 @@ namespace SqlParser\Tests\Components; +use SqlParser\Parser; use SqlParser\Components\ArrayObj; use SqlParser\Tests\TestCase; @@ -21,6 +22,22 @@ class ArrayObjTest extends TestCase $this->assertEquals('(a, b)', ArrayObj::build($component)); } + public function testParseType() + { + $components = ArrayObj::parse( + new Parser(), + $this->getTokensList('(1 + 2, 3 + 4)'), + array( + 'type' => 'SqlParser\\Components\\Expression', + 'typeOptions' => array( + 'noBrackets' => true, + ), + ) + ); + $this->assertEquals($components[0]->expr, '1 + 2'); + $this->assertEquals($components[1]->expr, '3 + 4'); + } + /** * @dataProvider testParseProvider */ diff --git a/tests/Components/PartitionDefinitionTest.php b/tests/Components/PartitionDefinitionTest.php new file mode 100644 index 0000000..9a1819c --- /dev/null +++ b/tests/Components/PartitionDefinitionTest.php @@ -0,0 +1,24 @@ +<?php + +namespace SqlParser\Tests\Components; + +use SqlParser\Parser; +use SqlParser\Components\PartitionDefinition; + +use SqlParser\Tests\TestCase; + +class PartitionDefinitionTest extends TestCase +{ + + public function testParse() + { + $component = PartitionDefinition::parse( + new Parser(), + $this->getTokensList('PARTITION p0 VALUES LESS THAN(1990)') + ); + $this->assertFalse($component->isSubpartition); + $this->assertEquals('p0', $component->name); + $this->assertEquals('LESS THAN', $component->type); + $this->assertEquals('(1990)', $component->expr->expr); + } +} |