Skip to content

Commit 23d0522

Browse files
committed
Add unit test for the case "$v === null and $k has operator"
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().
1 parent 7880563 commit 23d0522

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/system/Database/Builder/WhereTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ public function testWhereAssociateArray()
111111
$this->assertSame($expectedBinds, $builder->getBinds());
112112
}
113113

114+
public function testWhereAssociateArrayKeyHasEqualValueIsNull()
115+
{
116+
$builder = $this->db->table('users');
117+
118+
$where = [
119+
'deleted_at =' => null,
120+
];
121+
122+
$expectedSQL = 'SELECT * FROM "users" WHERE "deleted_at" IS NULL';
123+
$expectedBinds = [];
124+
125+
$builder->where($where);
126+
$this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect()));
127+
$this->assertSame($expectedBinds, $builder->getBinds());
128+
}
129+
114130
public function testWhereCustomString()
115131
{
116132
$builder = $this->db->table('jobs');

0 commit comments

Comments
 (0)