diff options
Diffstat (limited to 'tests/Components/CaseExpressionTest.php')
-rw-r--r-- | tests/Components/CaseExpressionTest.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/Components/CaseExpressionTest.php b/tests/Components/CaseExpressionTest.php index 263775d..8746909 100644 --- a/tests/Components/CaseExpressionTest.php +++ b/tests/Components/CaseExpressionTest.php @@ -33,4 +33,56 @@ class CaseExpressionTest extends TestCase 'CASE WHEN 1=1 THEN "India" ELSE "Other" END' ); } + + public function testParseBuild3() + { + $caseExprQuery = 'case 1 when 1 then "Some" ' + . 'when 2 then "SomeOther" else "Other" end'; + $component = CaseExpression::parse( + new Parser(), + $this->getTokensList($caseExprQuery)); + $this->assertEquals( + CaseExpression::build($component), + 'CASE 1 WHEN 1 THEN "Some" WHEN 2 THEN "SomeOther" ELSE "Other" END' + ); + } + + public function testParseBuild4() + { + $caseExprQuery = 'case 1 when 1 then "Some" ' + . 'when 2 then "SomeOther" end'; + $component = CaseExpression::parse( + new Parser(), + $this->getTokensList($caseExprQuery)); + $this->assertEquals( + CaseExpression::build($component), + 'CASE 1 WHEN 1 THEN "Some" WHEN 2 THEN "SomeOther" END' + ); + } + + public function testParseBuild5() + { + $caseExprQuery = 'case when 1=1 then "Some" ' + . 'when 1=2 then "SomeOther" else "Other" end'; + $component = CaseExpression::parse( + new Parser(), + $this->getTokensList($caseExprQuery)); + $this->assertEquals( + CaseExpression::build($component), + 'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" ELSE "Other" END' + ); + } + + public function testParseBuild6() + { + $caseExprQuery = 'case when 1=1 then "Some" ' + . 'when 1=2 then "SomeOther" end'; + $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' + ); + } } |