Skip to content

Commit 227f2d0

Browse files
committed
add test for invalid keys and values throw \InvalidArgumentException
1 parent a9ac0bb commit 227f2d0

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/system/Database/Builder/WhereTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,49 @@ public function testWhereInClosure()
221221

222222
//--------------------------------------------------------------------
223223

224+
public function provideInvalidKeys()
225+
{
226+
return [
227+
'null' => [null],
228+
'empty string' => [''],
229+
];
230+
}
231+
232+
/**
233+
* @dataProvider provideInvalidKeys
234+
*/
235+
public function testWhereInvalidKeyThrowInvalidArgumentException($key)
236+
{
237+
$this->expectException(\InvalidArgumentException::class);
238+
$builder = $this->db->table('jobs');
239+
240+
$builder->whereIn($key, ['Politician', 'Accountant']);
241+
}
242+
243+
//--------------------------------------------------------------------
244+
245+
public function provideInvalidValues()
246+
{
247+
return [
248+
'null' => [null],
249+
'not array' => ['not array'],
250+
'not instanceof \Closure' => [new \stdClass],
251+
];
252+
}
253+
254+
/**
255+
* @dataProvider provideInvalidValues
256+
*/
257+
public function testWhereInEmptyValuesThrowInvalidArgumentException($values)
258+
{
259+
$this->expectException(\InvalidArgumentException::class);
260+
$builder = $this->db->table('jobs');
261+
262+
$builder->whereIn('name', $values);
263+
}
264+
265+
//--------------------------------------------------------------------
266+
224267
public function testWhereNotIn()
225268
{
226269
$builder = $this->db->table('jobs');

0 commit comments

Comments
 (0)