File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -869,7 +869,7 @@ protected function render(array $data): JsonResponse
869869 $ output = $ this ->attachAppends ([
870870 'draw ' => $ this ->request ->draw (),
871871 'recordsTotal ' => $ this ->totalRecords ,
872- 'recordsFiltered ' => $ this ->filteredRecords ,
872+ 'recordsFiltered ' => $ this ->filteredRecords ?? 0 ,
873873 'data ' => $ data ,
874874 ]);
875875
Original file line number Diff line number Diff line change @@ -25,6 +25,19 @@ public function it_returns_all_records_when_no_parameters_is_passed()
2525 ]);
2626 }
2727
28+ /** @test */
29+ public function it_returns_zero_filtered_records_on_empty_collection ()
30+ {
31+ $ crawler = $ this ->call ('GET ' , '/collection/empty ' );
32+ $ crawler ->assertExactJson ([
33+ "data " => [],
34+ "draw " => 0 ,
35+ "input " => [],
36+ 'recordsTotal ' => 0 ,
37+ 'recordsFiltered ' => 0 ,
38+ ]);
39+ }
40+
2841 /** @test */
2942 public function it_can_perform_global_search ()
3043 {
@@ -242,5 +255,9 @@ protected function setUp(): void
242255 $ this ->app ['router ' ]->get ('/collection/users ' , function (DataTables $ datatables ) {
243256 return $ datatables ->collection (User::all ())->toJson ();
244257 });
258+
259+ $ this ->app ['router ' ]->get ('/collection/empty ' , function (DataTables $ datatables ) {
260+ return $ datatables ->collection ([])->toJson ();
261+ });
245262 }
246263}
You can’t perform that action at this time.
0 commit comments