From 0858d0a834c683c4e7bc161b1148112cf917815c Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Fri, 26 Jun 2015 00:13:08 +0200 Subject: [PATCH] added test for querybuilder select close #8895 --- tests/framework/db/QueryBuilderTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/framework/db/QueryBuilderTest.php b/tests/framework/db/QueryBuilderTest.php index a8256d93e2..3ccc29b808 100644 --- a/tests/framework/db/QueryBuilderTest.php +++ b/tests/framework/db/QueryBuilderTest.php @@ -468,6 +468,25 @@ class QueryBuilderTest extends DatabaseTestCase $this->assertEmpty($params); } + public function testComplexSelect() + { + $query = (new Query()) + ->select([ + 'ID' => 't.id', + 'gsm.username as GSM', + 'part.Part', + 'Part Cost' => 't.Part_Cost', + new Expression("case t.Status_Id when 1 then 'Acknowledge' when 2 then 'No Action' else 'Unknown Action' END as [[Next Action]]"), + ]) + ->from('tablename'); + list ($sql, $params) = $this->getQueryBuilder()->build($query); + $expected = $this->replaceQuotes( + 'SELECT `t`.`id` AS `ID`, `gsm`.`username` AS `GSM`, `part`.`Part`, `t`.`Part_Cost` AS `Part Cost`,' + . ' case t.Status_Id when 1 then \'Acknowledge\' when 2 then \'No Action\' else \'Unknown Action\' END as [[Next Action]] FROM `tablename`'); + $this->assertEquals($expected, $sql); + $this->assertEmpty($params); + } + public function testCompositeInCondition() { $condition = [