Skip to content

Commit 5a598ff

Browse files
Added unit tests for CASE/WHEN in PHQL #651
1 parent 503274b commit 5a598ff

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

unit-tests/ModelsQueryExecuteTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,18 @@ public function _testSelectExecute($di)
423423
$this->assertEquals(2, $result[0]->{"0"});
424424
$this->assertInstanceOf('Phalcon\Mvc\Model\Row', $result[0]);
425425

426+
$result = $manager->executeQuery('SELECT CASE 1 WHEN 1 THEN 2 END FROM Robots');
427+
$this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Complex', $result);
428+
$this->assertEquals(2, $result[0]->{"0"});
429+
430+
$result = $manager->executeQuery('SELECT CASE 2 WHEN 1 THEN 2 WHEN 2 THEN 3 END FROM Robots');
431+
$this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Complex', $result);
432+
$this->assertEquals(3, $result[0]->{"0"});
433+
434+
$result = $manager->executeQuery('SELECT CASE 2 WHEN 1 THEN 2 ELSE 3 END FROM Robots');
435+
$this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Complex', $result);
436+
$this->assertEquals(3, $result[0]->{"0"});
437+
426438
// Issue 1011
427439
/*$result = $manager->executeQuery('SELECT r.name le_name FROM Robots r ORDER BY r.name ASC LIMIT ?1,?2',
428440
array(1 => 1, 2 => 2),

0 commit comments

Comments
 (0)