Skip to content

Commit f6020f3

Browse files
committed
add test case for empty array
1 parent 9db4cd0 commit f6020f3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/wpunit/Traits/Custom_Table_Query_MethodsTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,43 @@ public function should_get_all_by_with_array_values() {
117117
$this->assertEquals( 0, $results[2]['status'] );
118118
}
119119

120+
/**
121+
* @test
122+
*/
123+
public function should_handle_empty_array() {
124+
$table = $this->get_query_test_table();
125+
Register::table( $table );
126+
127+
// Insert test data
128+
$table::insert( [
129+
'name' => 'Test 1',
130+
'slug' => 'test-1',
131+
'status' => 1,
132+
] );
133+
134+
$id1 = DB::last_insert_id();
135+
136+
$table::insert( [
137+
'name' => 'Test 2',
138+
'slug' => 'test-2',
139+
'status' => 1,
140+
] );
141+
142+
$id2 = DB::last_insert_id();
143+
144+
$table::insert( [
145+
'name' => 'Test 3',
146+
'slug' => 'test-3',
147+
'status' => 0,
148+
] );
149+
150+
$id3 = DB::last_insert_id();
151+
152+
$results = $table::get_all_by( 'status', [], 'IN' );
153+
154+
$this->assertEmpty( $results );
155+
}
156+
120157
/**
121158
* @test
122159
*/

0 commit comments

Comments
 (0)