Skip to content

Commit

Permalink
Added unit tests for CASE/WHEN in PHQL #651
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed Jun 5, 2015
1 parent 503274b commit 5a598ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions unit-tests/ModelsQueryExecuteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,18 @@ public function _testSelectExecute($di)
$this->assertEquals(2, $result[0]->{"0"});
$this->assertInstanceOf('Phalcon\Mvc\Model\Row', $result[0]);

$result = $manager->executeQuery('SELECT CASE 1 WHEN 1 THEN 2 END FROM Robots');
$this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Complex', $result);
$this->assertEquals(2, $result[0]->{"0"});

$result = $manager->executeQuery('SELECT CASE 2 WHEN 1 THEN 2 WHEN 2 THEN 3 END FROM Robots');
$this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Complex', $result);
$this->assertEquals(3, $result[0]->{"0"});

$result = $manager->executeQuery('SELECT CASE 2 WHEN 1 THEN 2 ELSE 3 END FROM Robots');
$this->assertInstanceOf('Phalcon\Mvc\Model\Resultset\Complex', $result);
$this->assertEquals(3, $result[0]->{"0"});

// Issue 1011
/*$result = $manager->executeQuery('SELECT r.name le_name FROM Robots r ORDER BY r.name ASC LIMIT ?1,?2',
array(1 => 1, 2 => 2),
Expand Down

0 comments on commit 5a598ff

Please sign in to comment.