File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ public function test_can_get_the_column_view(): void
2424
2525 }
2626
27+
2728 public function test_can_infer_field_name_from_title_if_no_from (): void
2829 {
2930 $ column = ColorColumn::make ('Favorite Color ' );
@@ -176,4 +177,32 @@ function ($row) {
176177 $ this ->assertSame ('#008000 ' , $ column ->getColor ($ rows ->slice (2 , 1 )->first ()));
177178
178179 }
180+
181+ public function test_can_get_column_get_contents_from_color (): void
182+ {
183+ $ column = ColorColumn::make ('Species Color ' )->color (
184+ function ($ row ) {
185+ if ($ row ->species_id == 1 ) {
186+ return '#ff0000 ' ;
187+ } elseif ($ row ->species_id == 2 ) {
188+ return '#008000 ' ;
189+ } else {
190+ return '#ffa500 ' ;
191+ }
192+
193+ }
194+ );
195+ $ rows = $ this ->basicTable ->setAdditionalSelects (['pets.species_id as species_id ' ])->getRows ();
196+
197+ $ contents1 = $ column ->getContents ($ rows ->first ());
198+ $ this ->assertSame ($ contents1 ['color ' ], '#ff0000 ' );
199+ $ this ->assertSame ($ contents1 ['isTailwind ' ], true );
200+ $ this ->assertSame ($ contents1 ['isBootstrap ' ], false );
201+
202+ $ contents2 = $ column ->getContents ($ rows ->last ());
203+ $ this ->assertSame ($ contents2 ['color ' ], '#ffa500 ' );
204+ $ this ->assertSame ($ contents2 ['isTailwind ' ], true );
205+ $ this ->assertSame ($ contents2 ['isBootstrap ' ], false );
206+
207+ }
179208}
You can’t perform that action at this time.
0 commit comments