@@ -41,24 +41,6 @@ public function it_can_set_zero_total_records()
4141 ]);
4242 }
4343
44- #[Test]
45- public function it_can_set_skip_total_records ()
46- {
47- DB ::enableQueryLog ();
48-
49- $ crawler = $ this ->call ('GET ' , '/skip-total-records ' );
50- $ crawler ->assertJson ([
51- 'draw ' => 0 ,
52- 'recordsTotal ' => 0 ,
53- 'recordsFiltered ' => 20 ,
54- ]);
55-
56- DB ::disableQueryLog ();
57- $ queryLog = DB ::getQueryLog ();
58-
59- $ this ->assertCount (2 , $ queryLog );
60- }
61-
6244 #[Test]
6345 public function it_can_set_total_filtered_records ()
6446 {
@@ -109,7 +91,27 @@ public function it_can_perform_global_search()
10991 #[Test]
11092 public function it_can_skip_total_records_count_query ()
11193 {
112- $ crawler = $ this ->call ('GET ' , '/query/simple ' , [
94+ DB ::enableQueryLog ();
95+
96+ $ crawler = $ this ->call ('GET ' , '/skip-total-records ' );
97+ $ crawler ->assertJson ([
98+ 'draw ' => 0 ,
99+ 'recordsTotal ' => 20 ,
100+ 'recordsFiltered ' => 20 ,
101+ ]);
102+
103+ DB ::disableQueryLog ();
104+ $ queryLog = DB ::getQueryLog ();
105+
106+ $ this ->assertCount (2 , $ queryLog );
107+ }
108+
109+ #[Test]
110+ public function it_can_skip_total_records_count_query_with_filter_applied ()
111+ {
112+ DB ::enableQueryLog ();
113+
114+ $ crawler = $ this ->call ('GET ' , '/skip-total-records ' , [
113115 'columns ' => [
114116 ['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
115117 ['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
@@ -119,9 +121,14 @@ public function it_can_skip_total_records_count_query()
119121
120122 $ crawler ->assertJson ([
121123 'draw ' => 0 ,
122- 'recordsTotal ' => 0 ,
124+ 'recordsTotal ' => 1 ,
123125 'recordsFiltered ' => 1 ,
124126 ]);
127+
128+ DB ::disableQueryLog ();
129+ $ queryLog = DB ::getQueryLog ();
130+
131+ $ this ->assertCount (2 , $ queryLog );
125132 }
126133
127134 #[Test]
@@ -411,8 +418,6 @@ protected function setUp(): void
411418 ->formatColumn ('created_at ' , new DateFormatter ('Y-m-d ' ))
412419 ->toJson ());
413420
414- $ router ->get ('/query/simple ' , fn (DataTables $ dataTable ) => $ dataTable ->query (DB ::table ('users ' ))->skipTotalRecords ()->toJson ());
415-
416421 $ router ->get ('/query/addColumn ' , fn (DataTables $ dataTable ) => $ dataTable ->query (DB ::table ('users ' ))
417422 ->addColumn ('foo ' , 'bar ' )
418423 ->toJson ());
0 commit comments