Skip to content

Commit 02bdcbb

Browse files
committed
Add test for yajra#2102.
1 parent a4f37b7 commit 02bdcbb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Integration/QueryDataTableTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@ public function it_allows_search_on_added_column_with_custom_filter_handler()
229229
$this->assertStringContainsString('"1" = ?', $queries[1]['query']);
230230
}
231231

232+
/** @test */
233+
public function it_allows_column_search_added_column_with_custom_filter_handler()
234+
{
235+
$crawler = $this->call('GET', '/query/blacklisted-filter', [
236+
'columns' => [
237+
['data' => 'foo', 'name' => 'foo', 'searchable' => 'true', 'orderable' => 'true', 'search' => ['value' => 'Record-1']],
238+
['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'],
239+
['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'],
240+
],
241+
'search' => ['value' => ''],
242+
]);
243+
244+
$crawler->assertJson([
245+
'draw' => 0,
246+
'recordsTotal' => 20,
247+
'recordsFiltered' => 1,
248+
]);
249+
}
250+
232251
protected function setUp(): void
233252
{
234253
parent::setUp();
@@ -264,6 +283,16 @@ protected function setUp(): void
264283
->toJson();
265284
});
266285

286+
$route->get('/query/blacklisted-filter', function (DataTables $dataTable) {
287+
return $dataTable->query(DB::table('users'))
288+
->addColumn('foo', 'bar')
289+
->filterColumn('foo', function (Builder $builder, $keyword) {
290+
$builder->where('name', $keyword);
291+
})
292+
->blacklist(['foo'])
293+
->toJson();
294+
});
295+
267296
$route->get('/query/only', function (DataTables $dataTable) {
268297
return $dataTable->query(DB::table('users'))
269298
->addColumn('foo', 'bar')

0 commit comments

Comments
 (0)