diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-07-10 01:45:45 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-07-10 03:47:19 +0300 |
commit | 527842708bf44fe2bb4d17a97203cec01b860960 (patch) | |
tree | 9eb52c23199199b721b5412e1c16d9129d624e52 /tests/Components/OptionsArrayTest.php | |
parent | 7c925b68763e86be121664575632c9261d380821 (diff) | |
download | sql-parser-527842708bf44fe2bb4d17a97203cec01b860960.zip sql-parser-527842708bf44fe2bb4d17a97203cec01b860960.tar.gz sql-parser-527842708bf44fe2bb4d17a97203cec01b860960.tar.bz2 |
Mass renaming. Using 'component' instead of 'fragment'.
Diffstat (limited to 'tests/Components/OptionsArrayTest.php')
-rw-r--r-- | tests/Components/OptionsArrayTest.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/Components/OptionsArrayTest.php b/tests/Components/OptionsArrayTest.php new file mode 100644 index 0000000..0c453da --- /dev/null +++ b/tests/Components/OptionsArrayTest.php @@ -0,0 +1,65 @@ +<?php + +namespace SqlParser\Tests\Components; + +use SqlParser\Parser; +use SqlParser\Components\OptionsArray; + +use SqlParser\Tests\TestCase; + +class OptionsArrayTest extends TestCase +{ + + public function testParse() + { + $component = OptionsArray::parse( + new Parser(), + $this->getTokensList('A B = (test) C'), + array( + 'A' => 1, + 'B' => array(2, 'var'), + 'C' => 3, + ) + ); + $this->assertEquals( + array( + 1 => 'A', + 2 => array( + 'name' => 'B', + 'value' => 'test', + 'value_' => 'test', + 'equal' => false, + ), + 3 => 'C', + ), + $component->options + ); + } + + public function testMerge() + { + $component = new OptionsArray(array('a')); + $component->merge(array('b', 'c')); + $this->assertEquals($component->options, array('a', 'b', 'c')); + } + + public function testBuild() + { + $component = new OptionsArray( + array( + 'ALL', + 'SQL_CALC_FOUND_ROWS', + array( + 'name' => 'MAX_STATEMENT_TIME', + 'value' => '42', + 'value_' => '42', + 'equal' => true, + ), + ) + ); + $this->assertEquals( + OptionsArray::build($component), + 'ALL SQL_CALC_FOUND_ROWS MAX_STATEMENT_TIME=42' + ); + } +} |