Skip to content

Commit 6a3a75e

Browse files
committed
adds tests
Took 13 minutes
1 parent f86287b commit 6a3a75e

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/Traits/WithBulkActions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function resetBulk(): void
6565
public function selectedRowsQuery()
6666
{
6767
return (clone $this->rowsQuery())
68-
->unless($this->selectAll, fn ($query) => $query->whereIn($query->qualifyColumn($this->primaryKey), $this->selected));
68+
->unless($this->selectAll, fn ($query) => $query->whereIn($this->primaryKey, $this->selected));
6969
}
7070

7171
/**

tests/Http/Livewire/CatsTable.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
class CatsTable extends DataTableComponent
1313
{
14+
public array $bulkActions = [
15+
'feed' => 'Feed selected',
16+
];
17+
1418
public function query(): Relation
1519
{
1620
/** @var Species $dogSpecimen */
@@ -36,4 +40,8 @@ public function columns(): array
3640
->searchable(),
3741
];
3842
}
43+
44+
public function feed(): int{
45+
return $this->selectedRowsQuery()->count();
46+
}
3947
}

tests/RelationshipDataTableComponentTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Rappasoft\LaravelLivewireTables\Tests;
44

5+
use Amp\ByteStream\StreamException;
56
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
67
use Illuminate\Support\Collection;
78
use Rappasoft\LaravelLivewireTables\DataTableComponent;
@@ -97,4 +98,10 @@ public function search_filter_callback(): void
9798
$this->table->filters['search'] = '22';
9899
$this->assertEquals(1, $this->table->getRowsProperty()->total());
99100
}
101+
102+
/** @test */
103+
public function bulk_actions(){
104+
$this->table->selected[] = 1;
105+
$this->assertEquals(1, $this->table->feed());
106+
}
100107
}

0 commit comments

Comments
 (0)