44
55use PHPUnit \Framework \Attributes \Group ;
66use Rappasoft \LaravelLivewireTables \Exceptions \DataTableConfigurationException ;
7+ use Rappasoft \LaravelLivewireTables \Tests \Http \Livewire \PetsTable ;
78use Rappasoft \LaravelLivewireTables \Tests \TestCase ;
9+ use Rappasoft \LaravelLivewireTables \Views \Filters \MultiSelectFilter ;
10+ use Illuminate \Database \Eloquent \Builder ;
11+ use Rappasoft \LaravelLivewireTables \Tests \Models \Breed ;
812
913#[Group('Filters ' )]
1014final class FilterMenuTest extends TestCase
@@ -25,4 +29,88 @@ public function test_can_get_default_filter_slidedown_row_attributes(): void
2529 $ this ->assertSame (['class ' => '' , 'default-colors ' => true , 'default-styling ' => true , 'row ' => 2 ], $ this ->basicTable ->getFilterSlidedownRowAttributes ('2 ' ));
2630
2731 }
32+
33+ public function test_can_check_filters_with_no_defined_slidedown_rows (): void
34+ {
35+ $ testTableDefault = new class extends PetsTable
36+ {
37+ public function configure (): void
38+ {
39+ parent ::configure ();
40+ $ this ->useComputedPropertiesDisabled ();
41+
42+ }
43+
44+ public function publiclySetFilterPillsItemAttributes (array $ attributes = [])
45+ {
46+ $ this ->setFilterPillsItemAttributes ($ attributes );
47+ }
48+
49+ public function publiclySetResetFilterButtonAttributes (array $ attributes = [])
50+ {
51+ $ this ->setFilterPillsResetFilterButtonAttributes ($ attributes );
52+ }
53+
54+ public function publiclySetResetFilterAllButtonAttributes (array $ attributes = [])
55+ {
56+ $ this ->setFilterPillsResetAllButtonAttributes ($ attributes );
57+ }
58+ };
59+ $ this ->assertFalse ($ testTableDefault ->hasFiltersWithSlidedownRows ());
60+ }
61+
62+ public function test_can_check_filters_with_defined_slidedown_rows (): void
63+ {
64+ $ testTableDefault = new class extends PetsTable
65+ {
66+ public function configure (): void
67+ {
68+ parent ::configure ();
69+ $ this ->useComputedPropertiesDisabled ();
70+
71+ }
72+
73+ public function filters (): array
74+ {
75+ return [
76+ MultiSelectFilter::make ('Breed ' , 'breed ' )
77+ ->setFilterSlidedownRow (2 )
78+ ->options (
79+ Breed::query ()
80+ ->orderBy ('name ' )
81+ ->get ()
82+ ->keyBy ('id ' )
83+ ->map (fn ($ breed ) => $ breed ->name )
84+ ->toArray ()
85+ )
86+ ->filter (function (Builder $ builder , array $ values ) {
87+ return $ builder ->whereIn ('breed_id ' , $ values );
88+ }),
89+ ];
90+ }
91+
92+ public function publiclySetFilterPillsItemAttributes (array $ attributes = [])
93+ {
94+ $ this ->setFilterPillsItemAttributes ($ attributes );
95+ }
96+
97+ public function publiclySetResetFilterButtonAttributes (array $ attributes = [])
98+ {
99+ $ this ->setFilterPillsResetFilterButtonAttributes ($ attributes );
100+ }
101+
102+ public function publiclySetResetFilterAllButtonAttributes (array $ attributes = [])
103+ {
104+ $ this ->setFilterPillsResetAllButtonAttributes ($ attributes );
105+ }
106+ };
107+ $ this ->assertTrue ($ testTableDefault ->hasFiltersWithSlidedownRows ());
108+ }
109+
110+
111+ /*
112+ }*/
113+
114+
115+
28116}
0 commit comments