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
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,28 @@ public function testStandardSelect()
12
12
{
13
13
$magicQuery = newMagicQuery();
14
14
15
+
$sql = "SELECT id FROM users WHERE name LIKE :name LIMIT :offset, :limit";
16
+
$this->assertEquals("SELECT id FROM users WHERE name LIKE 'foo'", self::simplifySql($magicQuery->build($sql, ['name' => 'foo'])));
17
+
18
+
$sql = "SELECT id FROM users WHERE name LIKE :name LIMIT 2, :limit";
19
+
$this->assertEquals("SELECT id FROM users WHERE name LIKE 'foo' LIMIT 2, 10", self::simplifySql($magicQuery->build($sql, ['name' => 'foo', 'limit' => 10])));
20
+
21
+
try {
22
+
$exceptionOccurred = false;
23
+
$sql = "SELECT id FROM users WHERE name LIKE :name LIMIT 2, :limit";
// We have no limit provided in the parameters so we test that the script return an exception for this case
27
+
$exceptionOccurred = true;
28
+
}
29
+
$this->assertEquals(true, $exceptionOccurred);
30
+
31
+
$sql = "SELECT id FROM users WHERE name LIKE :name LIMIT :offset, 5";
32
+
$this->assertEquals("SELECT id FROM users WHERE name LIKE 'foo' LIMIT 0, 5", self::simplifySql($magicQuery->build($sql, ['name' => 'foo', 'offset' => 0])));
33
+
34
+
$sql = "SELECT id FROM users WHERE name LIKE :name LIMIT :offset, 5";
35
+
$this->assertEquals("SELECT id FROM users WHERE name LIKE 'foo' LIMIT 5", self::simplifySql($magicQuery->build($sql, ['name' => 'foo'])));
36
+
15
37
$sql = "SELECT id FROM users LIMIT 10";
16
38
$this->assertEquals("SELECT id FROM users LIMIT 10", self::simplifySql($magicQuery->build($sql)));
0 commit comments