diff --git a/tests/Zend/Db/Select/StaticTest.php b/tests/Zend/Db/Select/StaticTest.php index 8feffd198c..482c77efed 100644 --- a/tests/Zend/Db/Select/StaticTest.php +++ b/tests/Zend/Db/Select/StaticTest.php @@ -854,6 +854,26 @@ public function testSqlInjectionInColumn() $this->assertEquals('SELECT "p"."MD5(1); drop table products; -- )" FROM "products" AS "p"', $select->assemble()); } + public function testIfInColumn() + { + $select = $this->_db->select(); + $select->from('table1', '*'); + $select->join(array('table2'), + 'table1.id = table2.id', + array('bar' => 'IF(table2.id IS NOT NULL, 1, 0)')); + $this->assertEquals("SELECT \"table1\".*, IF(table2.id IS NOT NULL, 1, 0) AS \"bar\" FROM \"table1\"\n INNER JOIN \"table2\" ON table1.id = table2.id", $select->assemble()); + } + + public function testNestedIfInColumn() + { + $select = $this->_db->select(); + $select->from('table1', '*'); + $select->join(array('table2'), + 'table1.id = table2.id', + array('bar' => 'IF(table2.id IS NOT NULL, IF(table2.id2 IS NOT NULL, 1, 2), 0)')); + $this->assertEquals("SELECT \"table1\".*, IF(table2.id IS NOT NULL, IF(table2.id2 IS NOT NULL, 1, 2), 0) AS \"bar\" FROM \"table1\"\n INNER JOIN \"table2\" ON table1.id = table2.id", $select->assemble()); + } + /** * @group ZF-378 */