mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Also added the ability to pass in a callback function to the assertTableBulkActionDataSet
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Livewire\Features\SupportTesting {
|
||||
|
||||
public function setTableBulkActionData(array $data): static {}
|
||||
|
||||
public function assertTableBulkActionDataSet(array $data): static {}
|
||||
public function assertTableBulkActionDataSet(array | Closure $state): static {}
|
||||
|
||||
public function callTableBulkAction(string $name, array | Collection $records, array $data = [], array $arguments = []): static {}
|
||||
|
||||
|
||||
@@ -70,9 +70,15 @@ class TestsBulkActions
|
||||
|
||||
public function assertTableBulkActionDataSet(): Closure
|
||||
{
|
||||
return function (array $data): static {
|
||||
foreach (Arr::dot($data, prepend: 'mountedTableBulkActionData.') as $key => $value) {
|
||||
$this->assertSet($key, $value);
|
||||
return function (array | Closure $state): static {
|
||||
if ($state instanceof Closure) {
|
||||
$state = $state($this->get('mountedTableBulkActionData'));
|
||||
}
|
||||
|
||||
if (is_array($state)) {
|
||||
foreach (Arr::dot($state, prepend: 'mountedTableBulkActionData.') as $key => $value) {
|
||||
$this->assertSet($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -53,7 +53,10 @@ it('can set default bulk action data when mounted', function () {
|
||||
->mountTableBulkAction('data', records: $posts)
|
||||
->assertTableBulkActionDataSet([
|
||||
'foo' => 'bar',
|
||||
]);
|
||||
])
|
||||
->assertTableBulkActionDataSet(function (array $data): bool {
|
||||
return $data['foo'] === 'bar';
|
||||
});
|
||||
});
|
||||
|
||||
it('can call a bulk action with arguments', function () {
|
||||
|
||||
Reference in New Issue
Block a user