File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1515use Illuminate \Support \Arr ;
1616use Illuminate \Support \Collection ;
1717use Illuminate \Support \LazyCollection ;
18+ use Illuminate \Support \Traits \Macroable ;
1819use Maatwebsite \Excel \ExcelServiceProvider ;
1920use OpenSpout \Common \Entity \Style \Style ;
2021use Rap2hpoutre \FastExcel \FastExcel ;
2930
3031abstract class DataTable implements DataTableButtons
3132{
33+ use Macroable;
34+
3235 /**
3336 * DataTables print preview view.
3437 *
Original file line number Diff line number Diff line change 1010use Yajra \DataTables \Buttons \Tests \DataTables \UsersDataTable ;
1111use Yajra \DataTables \Buttons \Tests \Models \User ;
1212use Yajra \DataTables \EloquentDataTable ;
13+ use Yajra \DataTables \Services \DataTable ;
1314
1415class DataTableServiceTest extends TestCase
1516{
@@ -80,6 +81,20 @@ public function it_allows_response_callback(): void
8081 $ this ->assertEquals (1 , $ response ->json ('recordsFiltered ' ));
8182 }
8283
84+ #[Test]
85+ public function it_is_macroable (): void
86+ {
87+ $ dataTable = new class extends DataTable {};
88+
89+ $ this ->assertObjectHasProperty ('macros ' , $ dataTable );
90+ $ this ->assertTrue (method_exists ($ dataTable , 'macro ' ), 'Method macro does not exist. ' );
91+ $ this ->assertTrue (method_exists ($ dataTable , 'mixin ' ), 'Method mixin does not exist. ' );
92+
93+ DataTable::macro ('macroMethod ' , fn () => 'macro ' );
94+
95+ $ this ->assertEquals ('macro ' , $ dataTable ->macroMethod ());
96+ }
97+
8398 protected function setUp (): void
8499 {
85100 parent ::setUp ();
You can’t perform that action at this time.
0 commit comments