summaryrefslogtreecommitdiffstats
path: root/tests/Components/CaseExpressionTest.php
diff options
context:
space:
mode:
authorDeven Bansod <devenbansod.bits@gmail.com>2016-09-26 14:36:47 +0530
committerDeven Bansod <devenbansod.bits@gmail.com>2016-09-26 14:36:47 +0530
commit9da859827b973babb6c856d91d36a3dd5f101c05 (patch)
tree1fe1e76ee89472542e422137d6fb18e60061000a /tests/Components/CaseExpressionTest.php
parent7f4702adeab4a852ffc724971a601e28668fa6fe (diff)
downloadsql-parser-9da859827b973babb6c856d91d36a3dd5f101c05.zip
sql-parser-9da859827b973babb6c856d91d36a3dd5f101c05.tar.gz
sql-parser-9da859827b973babb6c856d91d36a3dd5f101c05.tar.bz2
Fix some issue with error reports and added testcases
Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
Diffstat (limited to 'tests/Components/CaseExpressionTest.php')
-rw-r--r--tests/Components/CaseExpressionTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/Components/CaseExpressionTest.php b/tests/Components/CaseExpressionTest.php
new file mode 100644
index 0000000..263775d
--- /dev/null
+++ b/tests/Components/CaseExpressionTest.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace SqlParser\Tests\Components;
+
+use SqlParser\Parser;
+use SqlParser\Components\CaseExpression;
+
+use SqlParser\Tests\TestCase;
+
+class CaseExpressionTest extends TestCase
+{
+
+ public function testParseBuild()
+ {
+ $caseExprQuery = 'case 1 when 1 then "Some" else "Other" end';
+ $component = CaseExpression::parse(
+ new Parser(),
+ $this->getTokensList($caseExprQuery));
+ $this->assertEquals(
+ CaseExpression::build($component),
+ 'CASE 1 WHEN 1 THEN "Some" ELSE "Other" END'
+ );
+ }
+
+ public function testParseBuild2()
+ {
+ $caseExprQuery = 'case when 1=1 then "India" else "Other" end';
+ $component = CaseExpression::parse(
+ new Parser(),
+ $this->getTokensList($caseExprQuery));
+ $this->assertEquals(
+ CaseExpression::build($component),
+ 'CASE WHEN 1=1 THEN "India" ELSE "Other" END'
+ );
+ }
+}