Skip to content

Commit

Permalink
Add component build tests from CASE expressions with aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
mostertb committed Oct 13, 2018
1 parent 6f76011 commit 61343f6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/Components/CaseExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,32 @@ public function testParseBuild6()
'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`'
);
}
}

0 comments on commit 61343f6

Please sign in to comment.