diff --git a/tests/DataTableComponentTest.php b/tests/DataTableComponentTest.php index a0db41dc2..a2a21971b 100644 --- a/tests/DataTableComponentTest.php +++ b/tests/DataTableComponentTest.php @@ -114,4 +114,11 @@ public function search_filter_alt_query_relation() $this->tableAltQuery->filters['search'] = 'Cat'; $this->assertEquals(2, $this->tableAltQuery->rows->total()); } + + /** @test */ + public function bulk_actions_defined_with_function() + { + $this->table->selected[] = 1; + $this->assertEquals(1, $this->table->count()); + } } diff --git a/tests/Http/Livewire/PetsTable.php b/tests/Http/Livewire/PetsTable.php index e5e2a7f45..da3d03be9 100644 --- a/tests/Http/Livewire/PetsTable.php +++ b/tests/Http/Livewire/PetsTable.php @@ -9,6 +9,11 @@ class PetsTable extends DataTableComponent { + public function bulkActions(): array + { + return [ 'count' => 'Count selected']; + } + /** * @return Builder */ @@ -36,4 +41,9 @@ public function columns(): array ->searchable(), ]; } + + public function count(): int + { + return $this->selectedRowsQuery()->count(); + } }