summaryrefslogtreecommitdiffstats
path: root/tests/Components/CaseExpressionTest.php
diff options
context:
space:
mode:
authorIsaac Bennetch <bennetch@gmail.com>2018-12-24 11:44:06 -0500
committerGitHub <noreply@github.com>2018-12-24 11:44:06 -0500
commitc8febda27875d0f33af2f47fffa451abbf599747 (patch)
tree65b61ca483f5acb8028921da555e7fdbc9f31781 /tests/Components/CaseExpressionTest.php
parente497100c9d0053aa2ac64111dd7ee3a4b801d62d (diff)
parentbf4ad3d3b148ce0868339ee24bca9a5c46821063 (diff)
downloadsql-parser-c8febda27875d0f33af2f47fffa451abbf599747.zip
sql-parser-c8febda27875d0f33af2f47fffa451abbf599747.tar.gz
sql-parser-c8febda27875d0f33af2f47fffa451abbf599747.tar.bz2
Merge pull request #203 from mostertb/case-alias
Add support for Aliases on CASE expressions
Diffstat (limited to 'tests/Components/CaseExpressionTest.php')
-rw-r--r--tests/Components/CaseExpressionTest.php28
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`'
+ );
+ }
}