Skip to content

Commit c9c594e

Browse files
authored
Merge pull request #2052 from MGatner/tests-where-null
Add various tests for (not) null
2 parents 34efa01 + cd83bdf commit c9c594e

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

tests/system/Database/Live/WhereTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,60 @@ public function testSubQueryAnotherType()
159159

160160
//--------------------------------------------------------------------
161161

162+
public function testWhereNullParam()
163+
{
164+
$this->db->table('job')
165+
->insert([
166+
'name' => 'Brewmaster',
167+
'description' => null,
168+
]);
169+
170+
$jobs = $this->db->table('job')
171+
->where('description', null)
172+
->get()
173+
->getResult();
174+
175+
$this->assertCount(1, $jobs);
176+
$this->assertEquals('Brewmaster', $jobs[0]->name);
177+
}
178+
179+
//--------------------------------------------------------------------
180+
181+
public function testWhereIsNull()
182+
{
183+
$this->db->table('job')
184+
->insert([
185+
'name' => 'Brewmaster',
186+
'description' => null,
187+
]);
188+
189+
$jobs = $this->db->table('job')
190+
->where('description IS NULL')
191+
->get()
192+
->getResult();
193+
194+
$this->assertCount(1, $jobs);
195+
$this->assertEquals('Brewmaster', $jobs[0]->name);
196+
}
197+
198+
//--------------------------------------------------------------------
199+
200+
public function testWhereIsNotNull()
201+
{
202+
$this->db->table('job')
203+
->insert([
204+
'name' => 'Brewmaster',
205+
'description' => null,
206+
]);
207+
208+
$jobs = $this->db->table('job')
209+
->where('description IS NOT NULL')
210+
->get()
211+
->getResult();
212+
213+
$this->assertCount(4, $jobs);
214+
}
215+
216+
//--------------------------------------------------------------------
217+
162218
}

0 commit comments

Comments
 (0)