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 Nov 5, 2021
1 parent 65b8569 commit 68ad987
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/system/Database/Builder/WhereTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ public function testWhereAssociateArray()
$this->assertSame($expectedBinds, $builder->getBinds());
}

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

$where = [
'deleted_at =' => null,
];

$expectedSQL = 'SELECT * FROM "users" WHERE "deleted_at" IS NULL';
$expectedBinds = [];

$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 68ad987

Please sign in to comment.