Skip to content

Commit

Permalink
Merge 4b4775d into ab36f3f
Browse files Browse the repository at this point in the history
  • Loading branch information
moufmouf committed Sep 11, 2019
2 parents ab36f3f + 4b4775d commit d27fc65
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/Mouf/Database/MagicQueryTest.php
Expand Up @@ -79,6 +79,12 @@ public function testStandardSelect()
$sql = 'SELECT * FROM users WHERE status IN :statuses';
$this->assertEquals('SELECT * FROM users WHERE status IN (\'1\',\'2\')', self::simplifySql($magicQuery->build($sql, ['statuses' => [1, 2]])));

$sql = 'SELECT * FROM users WHERE status not in :status';
$this->assertEquals("SELECT * FROM users WHERE status NOT IN ('2','4')", self::simplifySql($magicQuery->build($sql, ['status' => [2, 4]])));

$sql = 'SELECT * FROM users WHERE status not in (:status)';
$this->assertEquals("SELECT * FROM users WHERE status NOT IN ('2','4')", self::simplifySql($magicQuery->build($sql, ['status' => [2, 4]])));

$sql = 'SELECT * FROM myTable where someField BETWEEN :value1 AND :value2';
$this->assertEquals("SELECT * FROM myTable WHERE someField BETWEEN '2' AND '4'", self::simplifySql($magicQuery->build($sql, ['value1' => 2, 'value2' => 4])));
$this->assertEquals("SELECT * FROM myTable WHERE someField >= '2'", self::simplifySql($magicQuery->build($sql, ['value1' => 2])));
Expand Down Expand Up @@ -434,6 +440,10 @@ public function testBuildPreparedStatement()
// Let's check that MagicQuery is cleverly adding parenthesis if the user forgot those in the "IN" statement.
$sql = 'SELECT id FROM users WHERE status IN :status';
$this->assertEquals("SELECT id FROM users WHERE status IN (:status)", self::simplifySql($magicQuery->buildPreparedStatement($sql, ['status' => [1,2]])));

// Let's check that MagicQuery is cleverly adding parenthesis if the user forgot those in the "NOT IN" statement.
$sql = 'SELECT id FROM users WHERE status NOT IN :status';
$this->assertEquals("SELECT id FROM users WHERE status NOT IN (:status)", self::simplifySql($magicQuery->buildPreparedStatement($sql, ['status' => [1,2]])));
}

public function testSetOutputDialect()
Expand Down

0 comments on commit d27fc65

Please sign in to comment.