You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/Mouf/Database/MagicQueryTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,15 @@ public function testStandardSelect()
88
88
// Tests parameters with a ! (to force NULL values)
89
89
$sql = 'SELECT * FROM users WHERE status = :status!';
90
90
$this->assertEquals("SELECT * FROM users WHERE status = null", self::simplifySql($magicQuery->build($sql, ['status' => null])));
91
+
92
+
// Test CASE WHERE
93
+
$sql = "SELECT CASE WHEN status = 'on' THEN '1' WHEN status = 'off' THEN '0' ELSE '-1' END AS my_case FROM users";
94
+
$this->assertEquals("SELECT CASE WHEN status = 'on' THEN '1' WHEN status = 'off' THEN '0' ELSE '-1' END AS my_case FROM users", self::simplifySql($magicQuery->build($sql)));
95
+
96
+
// Test CASE WHERE like SWITCH CASE
97
+
$sql = "SELECT CASE status WHEN 'on' THEN '1' WHEN 'off' THEN '0' ELSE '-1' END AS my_case FROM users";
98
+
$this->assertEquals("SELECT CASE status WHEN 'on' THEN '1' WHEN 'off' THEN '0' ELSE '-1' END AS my_case FROM users", self::simplifySql($magicQuery->build($sql)));
0 commit comments