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
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,12 @@ public function testStandardSelect()
78
78
$sql = 'SELECT * FROM users WHERE status IN :statuses';
79
79
$this->assertEquals('SELECT * FROM users WHERE status IN (\'1\',\'2\')', self::simplifySql($magicQuery->build($sql, ['statuses' => [1, 2]])));
80
80
81
+
$sql = 'SELECT * FROM users WHERE status not in :status';
82
+
$this->assertEquals("SELECT * FROM users WHERE status NOT IN ('2','4')", self::simplifySql($magicQuery->build($sql, ['status' => [2, 4]])));
83
+
84
+
$sql = 'SELECT * FROM users WHERE status not in (:status)';
85
+
$this->assertEquals("SELECT * FROM users WHERE status NOT IN ('2','4')", self::simplifySql($magicQuery->build($sql, ['status' => [2, 4]])));
86
+
81
87
$sql = 'SELECT * FROM myTable where someField BETWEEN :value1 AND :value2';
82
88
$this->assertEquals("SELECT * FROM myTable WHERE someField BETWEEN '2' AND '4'", self::simplifySql($magicQuery->build($sql, ['value1' => 2, 'value2' => 4])));
83
89
$this->assertEquals("SELECT * FROM myTable WHERE someField >= '2'", self::simplifySql($magicQuery->build($sql, ['value1' => 2])));
@@ -433,5 +439,9 @@ public function testBuildPreparedStatement()
433
439
// Let's check that MagicQuery is cleverly adding parenthesis if the user forgot those in the "IN" statement.
434
440
$sql = 'SELECT id FROM users WHERE status IN :status';
435
441
$this->assertEquals("SELECT id FROM users WHERE status IN (:status)", self::simplifySql($magicQuery->buildPreparedStatement($sql, ['status' => [1,2]])));
442
+
443
+
// Let's check that MagicQuery is cleverly adding parenthesis if the user forgot those in the "NOT IN" statement.
444
+
$sql = 'SELECT id FROM users WHERE status NOT IN :status';
445
+
$this->assertEquals("SELECT id FROM users WHERE status NOT IN (:status)", self::simplifySql($magicQuery->buildPreparedStatement($sql, ['status' => [1,2]])));
0 commit comments