11<?php
22
33use PowerComponents \LivewirePowerGrid \Facades \Filter ;
4- use PowerComponents \LivewirePowerGrid \Tests \{Concerns \ Components \ DishesArrayTable ,
5- Concerns \Components \DishesCollectionTable ,
4+ use PowerComponents \LivewirePowerGrid \Tests \{
5+ Concerns \Components \DishesIterableTable ,
66 Concerns \Components \DishesQueryBuilderTable ,
77 Concerns \Components \DishesTable ,
88 Concerns \Components \DishesTableWithJoin };
@@ -131,7 +131,7 @@ public function filters(): array
131131 expect ($ component ->filters )
132132 ->toMatchArray ([]);
133133})->group ('filters ' , 'filterBoolean ' )
134- ->with ('filter_boolean_themes_collection ' , ' filter_boolean_themes_array ' );
134+ ->with ('iterable_datasource ' );
135135
136136it ('properly filters by bool true - using collection ' , function (string $ component , string $ theme ) {
137137 $ component = livewire ($ component , [
@@ -169,7 +169,7 @@ public function filters(): array
169169 expect ($ component ->filters )
170170 ->toMatchArray ([]);
171171})->group ('filters ' , 'filterBoolean ' )
172- ->with ('filter_boolean_themes_collection ' );
172+ ->with ('iterable_datasource ' );
173173
174174it ('properly filters by bool true - using collection - custom builder ' , function (string $ componentName , string $ theme ) {
175175 $ component = livewire ($ componentName , [
@@ -192,9 +192,9 @@ public function filters(): array
192192 ->assertSee ('Name 4 ' )
193193 ->assertDontSee ('Name 5 ' );
194194})->group ('filters ' , 'filterBoolean ' )
195- ->with ('filter_boolean_themes_collection ' );
195+ ->with ('iterable_datasource ' );
196196
197- $ customCollection = new class () extends DishesCollectionTable
197+ $ customCollection = new class () extends DishesIterableTable
198198{
199199 public int $ dishId ;
200200
@@ -214,7 +214,9 @@ public function filters(): array
214214};
215215
216216it ('properly filters by bool true - using collection - custom builder - using tablename in field ' , function (string $ component , string $ theme ) {
217- $ component = livewire ($ component )
217+ $ component = livewire ($ component , [
218+ 'iterableType ' => 'collection ' ,
219+ ])
218220 ->call ('setTestThemeClass ' , $ theme )
219221 ->assertSeeHtml ('wire:input.live.debounce.600ms="filterBoolean( \'in_stock \', $event.target.value, \'In Stock \')" ' );
220222
@@ -320,7 +322,7 @@ public function filters(): array
320322 expect ($ component ->filters )
321323 ->toMatchArray ([]);
322324})->group ('filters ' , 'filterBoolean ' )
323- ->with ('filter_boolean_themes_collection ' , ' filter_boolean_themes_array ' );
325+ ->with ('iterable_datasource ' );
324326
325327it ('properly filters by bool "all" ' , function (string $ component , object $ params ) {
326328 $ component = livewire ($ component , [
@@ -352,8 +354,10 @@ public function filters(): array
352354})->group ('filters ' , 'filterBoolean ' )
353355 ->with ('filter_boolean_join ' , 'filter_boolean_query_builder ' );
354356
355- it ('properly filters by bool "all" - using collection & array table ' , function (string $ component , string $ theme ) {
356- $ component = livewire ($ component )
357+ it ('properly filters by bool "all" - using collection ' , function (string $ component , string $ theme , string $ iterableType ) {
358+ $ component = livewire ($ component , [
359+ 'iterableType ' => $ iterableType ,
360+ ])
357361 ->call ('setTestThemeClass ' , $ theme );
358362
359363 expect ($ component ->filters )
@@ -373,7 +377,7 @@ public function filters(): array
373377 ],
374378 ]);
375379})->group ('filters ' , 'filterBoolean ' )
376- ->with ('filter_boolean_themes_collection ' , ' filter_boolean_themes_array ' );
380+ ->with ('iterable_datasource ' );
377381
378382dataset ('filter_boolean_join ' , [
379383 'tailwind -> id ' => [DishesTable::class, (object ) ['theme ' => \PowerComponents \LivewirePowerGrid \Themes \Tailwind::class, 'field ' => 'id ' ]],
@@ -390,14 +394,11 @@ public function filters(): array
390394 'daisyui query builder -> id ' => [DishesQueryBuilderTable::class, (object ) ['theme ' => \PowerComponents \LivewirePowerGrid \Themes \DaisyUI::class, 'field ' => 'id ' ]],
391395]);
392396
393- dataset ('filter_boolean_themes_array ' , [
394- [DishesArrayTable::class, \PowerComponents \LivewirePowerGrid \Themes \Tailwind::class],
395- [DishesArrayTable::class, \PowerComponents \LivewirePowerGrid \Themes \Bootstrap5::class],
396- [DishesArrayTable::class, \PowerComponents \LivewirePowerGrid \Themes \DaisyUI::class],
397- ]);
398-
399- dataset ('filter_boolean_themes_collection ' , [
400- 'tailwind ' => [DishesCollectionTable::class, \PowerComponents \LivewirePowerGrid \Themes \Tailwind::class],
401- 'bootstrap ' => [DishesCollectionTable::class, \PowerComponents \LivewirePowerGrid \Themes \Bootstrap5::class],
402- 'daisyui ' => [DishesCollectionTable::class, \PowerComponents \LivewirePowerGrid \Themes \DaisyUI::class],
397+ dataset ('iterable_datasource ' , [
398+ 'tailwind datasource array ' => [DishesIterableTable::class, \PowerComponents \LivewirePowerGrid \Themes \Tailwind::class, 'array ' ],
399+ 'bootstrap datasource array ' => [DishesIterableTable::class, \PowerComponents \LivewirePowerGrid \Themes \Bootstrap5::class, 'array ' ],
400+ 'daisyui datasource array ' => [DishesIterableTable::class, \PowerComponents \LivewirePowerGrid \Themes \DaisyUI::class, 'array ' ],
401+ 'tailwind datasource collection ' => [DishesIterableTable::class, \PowerComponents \LivewirePowerGrid \Themes \Tailwind::class, 'collection ' ],
402+ 'bootstrap datasource collection ' => [DishesIterableTable::class, \PowerComponents \LivewirePowerGrid \Themes \Bootstrap5::class, 'collection ' ],
403+ 'daisyui datasource collection ' => [DishesIterableTable::class, \PowerComponents \LivewirePowerGrid \Themes \DaisyUI::class, 'collection ' ],
403404]);
0 commit comments