@@ -41,24 +41,6 @@ public function it_can_set_zero_total_records()
41
41
]);
42
42
}
43
43
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
-
62
44
#[Test]
63
45
public function it_can_set_total_filtered_records ()
64
46
{
@@ -109,7 +91,27 @@ public function it_can_perform_global_search()
109
91
#[Test]
110
92
public function it_can_skip_total_records_count_query ()
111
93
{
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 ' , [
113
115
'columns ' => [
114
116
['data ' => 'name ' , 'name ' => 'name ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
115
117
['data ' => 'email ' , 'name ' => 'email ' , 'searchable ' => 'true ' , 'orderable ' => 'true ' ],
@@ -119,9 +121,14 @@ public function it_can_skip_total_records_count_query()
119
121
120
122
$ crawler ->assertJson ([
121
123
'draw ' => 0 ,
122
- 'recordsTotal ' => 0 ,
124
+ 'recordsTotal ' => 1 ,
123
125
'recordsFiltered ' => 1 ,
124
126
]);
127
+
128
+ DB ::disableQueryLog ();
129
+ $ queryLog = DB ::getQueryLog ();
130
+
131
+ $ this ->assertCount (2 , $ queryLog );
125
132
}
126
133
127
134
#[Test]
@@ -411,8 +418,6 @@ protected function setUp(): void
411
418
->formatColumn ('created_at ' , new DateFormatter ('Y-m-d ' ))
412
419
->toJson ());
413
420
414
- $ router ->get ('/query/simple ' , fn (DataTables $ dataTable ) => $ dataTable ->query (DB ::table ('users ' ))->skipTotalRecords ()->toJson ());
415
-
416
421
$ router ->get ('/query/addColumn ' , fn (DataTables $ dataTable ) => $ dataTable ->query (DB ::table ('users ' ))
417
422
->addColumn ('foo ' , 'bar ' )
418
423
->toJson ());
0 commit comments