1+ <?php
2+
3+ namespace Rappasoft \LaravelLivewireTables \Tests \Unit \Traits \Filters ;
4+
5+ use PHPUnit \Framework \Attributes \Group ;
6+ use Rappasoft \LaravelLivewireTables \Exceptions \DataTableConfigurationException ;
7+ use Rappasoft \LaravelLivewireTables \Tests \TestCase ;
8+ use Rappasoft \LaravelLivewireTables \Tests \Http \Livewire \PetsTable ;
9+
10+ #[Group('Filters ' )]
11+ final class FilterPillsTest extends TestCase
12+ {
13+ public function test_can_get_default_filter_pills_item_attributes (): void
14+ {
15+ $ this ->assertSame (['class ' => '' , 'default-colors ' => true , 'default-styling ' => true ], $ this ->basicTable ->getFilterPillsItemAttributes ());
16+ }
17+
18+ public function test_can_get_default_filter_reset_filter_button_attributes (): void
19+ {
20+ $ this ->assertSame (['class ' => '' , 'default-colors ' => true , 'default-styling ' => true ], $ this ->basicTable ->getFilterPillsResetFilterButtonAttributes ());
21+ }
22+
23+ public function test_can_get_default_filter_reset_all_filter_button_attributes (): void
24+ {
25+ $ this ->assertSame (['class ' => '' , 'default-colors ' => true , 'default-styling ' => true ], $ this ->basicTable ->getFilterPillsResetAllButtonAttributes ());
26+ }
27+
28+ public function test_can_change_default_filter_pills_item_attributes (): void
29+ {
30+ $ testTableDefault = new class extends PetsTable
31+ {
32+ public function configure (): void
33+ {
34+ parent ::configure ();
35+ $ this ->useComputedPropertiesDisabled ();
36+
37+ }
38+
39+ public function publiclySetFilterPillsItemAttributes (array $ attributes = [])
40+ {
41+ $ this ->setFilterPillsItemAttributes ($ attributes );
42+ }
43+
44+ public function publiclySetResetFilterButtonAttributes (array $ attributes = [])
45+ {
46+ $ this ->setFilterPillsResetFilterButtonAttributes ($ attributes );
47+ }
48+
49+ public function publiclySetResetFilterAllButtonAttributes (array $ attributes = [])
50+ {
51+ $ this ->setFilterPillsResetAllButtonAttributes ($ attributes );
52+ }
53+
54+ };
55+ $ this ->assertSame (['class ' => '' , 'default-colors ' => true , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsItemAttributes ());
56+ $ testTableDefault ->publiclySetFilterPillsItemAttributes (['class ' => 'bg-blue-500 ' ]);
57+ $ this ->assertSame (['class ' => 'bg-blue-500 ' , 'default-colors ' => true , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsItemAttributes ());
58+ $ testTableDefault ->publiclySetFilterPillsItemAttributes (['class ' => 'bg-blue-500 ' , 'default-colors ' => false ]);
59+ $ this ->assertSame (['class ' => 'bg-blue-500 ' , 'default-colors ' => false , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsItemAttributes ());
60+
61+ }
62+
63+ public function test_can_change_default_filter_pills_reset_button_attributes (): void
64+ {
65+ $ testTableDefault = new class extends PetsTable
66+ {
67+ public function configure (): void
68+ {
69+ parent ::configure ();
70+ $ this ->useComputedPropertiesDisabled ();
71+
72+ }
73+
74+ public function publiclySetFilterPillsItemAttributes (array $ attributes = [])
75+ {
76+ $ this ->setFilterPillsItemAttributes ($ attributes );
77+ }
78+
79+ public function publiclySetResetFilterButtonAttributes (array $ attributes = [])
80+ {
81+ $ this ->setFilterPillsResetFilterButtonAttributes ($ attributes );
82+ }
83+
84+ public function publiclySetResetFilterAllButtonAttributes (array $ attributes = [])
85+ {
86+ $ this ->setFilterPillsResetAllButtonAttributes ($ attributes );
87+ }
88+
89+ };
90+
91+ $ this ->assertSame (['class ' => '' , 'default-colors ' => true , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsResetFilterButtonAttributes ());
92+ $ testTableDefault ->publiclySetResetFilterButtonAttributes (['class ' => 'bg-red-500 ' ]);
93+ $ this ->assertSame (['class ' => 'bg-red-500 ' , 'default-colors ' => true , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsResetFilterButtonAttributes ());
94+ $ testTableDefault ->publiclySetResetFilterButtonAttributes (['class ' => 'bg-red-500 ' , 'default-colors ' => false ]);
95+ $ this ->assertSame (['class ' => 'bg-red-500 ' , 'default-colors ' => false , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsResetFilterButtonAttributes ());
96+
97+ }
98+
99+ public function test_can_change_default_filter_pills_reset_all_button_attributes (): void
100+ {
101+ $ testTableDefault = new class extends PetsTable
102+ {
103+ public function configure (): void
104+ {
105+ parent ::configure ();
106+ $ this ->useComputedPropertiesDisabled ();
107+
108+ }
109+
110+ public function publiclySetFilterPillsItemAttributes (array $ attributes = [])
111+ {
112+ $ this ->setFilterPillsItemAttributes ($ attributes );
113+ }
114+
115+ public function publiclySetResetFilterButtonAttributes (array $ attributes = [])
116+ {
117+ $ this ->setFilterPillsResetFilterButtonAttributes ($ attributes );
118+ }
119+
120+ public function publiclySetResetFilterAllButtonAttributes (array $ attributes = [])
121+ {
122+ $ this ->setFilterPillsResetAllButtonAttributes ($ attributes );
123+ }
124+ };
125+
126+ $ this ->assertSame (['class ' => '' , 'default-colors ' => true , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsResetAllButtonAttributes ());
127+ $ testTableDefault ->publiclySetResetFilterAllButtonAttributes (['class ' => 'bg-red-500 ' ]);
128+ $ this ->assertSame (['class ' => 'bg-red-500 ' , 'default-colors ' => true , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsResetAllButtonAttributes ());
129+ $ testTableDefault ->publiclySetResetFilterAllButtonAttributes (['class ' => 'bg-red-500 ' , 'default-colors ' => false ]);
130+ $ this ->assertSame (['class ' => 'bg-red-500 ' , 'default-colors ' => false , 'default-styling ' => true ], $ testTableDefault ->getFilterPillsResetAllButtonAttributes ());
131+
132+ }
133+
134+ }
0 commit comments