Skip to content

Commit

Permalink
Add unit test for the case "$v === null and $k has operator"
Browse files Browse the repository at this point in the history
For this code path: "elseif (preg_match('/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', $k ..."

The above code path "elseif (! $this->hasOperator($k) ..." is covered in testOrWhereInClosure() and testOrWhereNotInClosure().
  • Loading branch information
vlakoff committed Oct 30, 2021
1 parent 7880563 commit 172e044
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/system/Database/Builder/WhereTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ public function testWhereAssociateArray()
$this->assertSame($expectedBinds, $builder->getBinds());
}

public function testWhereAssociateArrayKeyHasEqualValueIsNull()
{
$builder = $this->db->table('user');

$where = [
'id <' => 100,
'col1 =' => null,
];

$expectedSQL = 'SELECT * FROM "user" WHERE "id" < 100 AND "col1" IS NULL';
$expectedBinds = [
'id' => [
100,
true,
],
];

$builder->where($where);
$this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect()));
$this->assertSame($expectedBinds, $builder->getBinds());
}

public function testWhereCustomString()
{
$builder = $this->db->table('jobs');
Expand Down

0 comments on commit 172e044

Please sign in to comment.