diff options
author | Brad Mostert <mostertb@users.noreply.github.com> | 2018-10-13 16:12:30 +0200 |
---|---|---|
committer | Brad Mostert <mostertb@users.noreply.github.com> | 2018-10-13 16:12:30 +0200 |
commit | 61343f63d0a64a14287f2366c2907b8a05eb0a87 (patch) | |
tree | c4045f1f2f4836a5f451bcd2a465f3d39931ba48 /tests | |
parent | 6f76011f86aed4f5645abef6da888c1ae0ee5bcb (diff) | |
download | sql-parser-61343f63d0a64a14287f2366c2907b8a05eb0a87.zip sql-parser-61343f63d0a64a14287f2366c2907b8a05eb0a87.tar.gz sql-parser-61343f63d0a64a14287f2366c2907b8a05eb0a87.tar.bz2 |
Add component build tests from CASE expressions with aliases
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Components/CaseExpressionTest.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/Components/CaseExpressionTest.php b/tests/Components/CaseExpressionTest.php index afe5e60..475486f 100644 --- a/tests/Components/CaseExpressionTest.php +++ b/tests/Components/CaseExpressionTest.php @@ -83,4 +83,32 @@ class CaseExpressionTest extends TestCase 'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" END' ); } + + public function testParseBuild7() + { + $caseExprQuery = 'case when 1=1 then "Some" ' + . 'when 1=2 then "SomeOther" end AS foo'; + $component = CaseExpression::parse( + new Parser(), + $this->getTokensList($caseExprQuery) + ); + $this->assertEquals( + CaseExpression::build($component), + 'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" END AS `foo`' + ); + } + + public function testParseBuild8() + { + $caseExprQuery = 'case when 1=1 then "Some" ' + . 'when 1=2 then "SomeOther" end foo'; + $component = CaseExpression::parse( + new Parser(), + $this->getTokensList($caseExprQuery) + ); + $this->assertEquals( + CaseExpression::build($component), + 'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" END AS `foo`' + ); + } } |