File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 15
15
use Illuminate \Support \Arr ;
16
16
use Illuminate \Support \Collection ;
17
17
use Illuminate \Support \LazyCollection ;
18
+ use Illuminate \Support \Traits \Macroable ;
18
19
use Maatwebsite \Excel \ExcelServiceProvider ;
19
20
use OpenSpout \Common \Entity \Style \Style ;
20
21
use Rap2hpoutre \FastExcel \FastExcel ;
29
30
30
31
abstract class DataTable implements DataTableButtons
31
32
{
33
+ use Macroable;
34
+
32
35
/**
33
36
* DataTables print preview view.
34
37
*
Original file line number Diff line number Diff line change 10
10
use Yajra \DataTables \Buttons \Tests \DataTables \UsersDataTable ;
11
11
use Yajra \DataTables \Buttons \Tests \Models \User ;
12
12
use Yajra \DataTables \EloquentDataTable ;
13
+ use Yajra \DataTables \Services \DataTable ;
13
14
14
15
class DataTableServiceTest extends TestCase
15
16
{
@@ -80,6 +81,20 @@ public function it_allows_response_callback(): void
80
81
$ this ->assertEquals (1 , $ response ->json ('recordsFiltered ' ));
81
82
}
82
83
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
+
83
98
protected function setUp (): void
84
99
{
85
100
parent ::setUp ();
You can’t perform that action at this time.
0 commit comments