diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-07-10 16:54:28 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-07-10 16:54:28 +0300 |
commit | 87cc627fdd144543bdac6264ec7c3dd5c3e824ab (patch) | |
tree | a0760fe475887b3ef817c8fabd55f2859fac54a3 /tests/Components/JoinKeywordTest.php | |
parent | 527842708bf44fe2bb4d17a97203cec01b860960 (diff) | |
download | sql-parser-87cc627fdd144543bdac6264ec7c3dd5c3e824ab.zip sql-parser-87cc627fdd144543bdac6264ec7c3dd5c3e824ab.tar.gz sql-parser-87cc627fdd144543bdac6264ec7c3dd5c3e824ab.tar.bz2 |
Imporved JOIN parsing and building.
Some keywords may appear in conditions.
Diffstat (limited to 'tests/Components/JoinKeywordTest.php')
-rw-r--r-- | tests/Components/JoinKeywordTest.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/Components/JoinKeywordTest.php b/tests/Components/JoinKeywordTest.php new file mode 100644 index 0000000..1130f5c --- /dev/null +++ b/tests/Components/JoinKeywordTest.php @@ -0,0 +1,36 @@ +<?php + +namespace SqlParser\Tests\Components; + +use SqlParser\Parser; +use SqlParser\Components\JoinKeyword; + +use SqlParser\Tests\TestCase; + +class JoinKeywordTest extends TestCase +{ + + public function testParseIncomplete() + { + $component = JoinKeyword::parse(new Parser(), $this->getTokensList('JOIN a')); + $this->assertEquals(1, count($component)); + $this->assertEquals('a', $component[0]->expr->expr); + $this->assertEquals(null, $component[0]->on); + } + + public function testBuild() + { + $component = JoinKeyword::parse( + new Parser(), + $this->getTokensList( + 'LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) '. + 'ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)' + ) + ); + $this->assertEquals( + 'LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) '. + 'ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)', + JoinKeyword::build($component) + ); + } +} |