File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 33namespace Yajra \DataTables \Buttons \Tests ;
44
55use Illuminate \Foundation \Testing \DatabaseTransactions ;
6+ use Illuminate \Http \Response ;
7+ use Symfony \Component \HttpFoundation \BinaryFileResponse ;
68use Yajra \DataTables \Buttons \Tests \DataTables \UsersDataTable ;
79
810class DataTableServiceTest extends TestCase
@@ -21,6 +23,39 @@ public function it_can_handle_ajax_request()
2123 ]);
2224 }
2325
26+ /** @test */
27+ public function it_returns_view_on_normal_get_request ()
28+ {
29+ $ response = $ this ->get ('users ' );
30+
31+ $ response ->assertSeeText ('users-table ' );
32+ $ response ->assertSeeText ('LaravelDataTables ' );
33+ }
34+
35+ /** @test */
36+ public function it_can_return_a_csv_file ()
37+ {
38+ $ response = $ this ->get ('users?action=csv ' );
39+
40+ $ this ->assertInstanceOf (BinaryFileResponse::class, $ response ->baseResponse );
41+ }
42+
43+ /** @test */
44+ public function it_can_return_a_xls_file ()
45+ {
46+ $ response = $ this ->get ('users?action=excel ' );
47+
48+ $ this ->assertInstanceOf (BinaryFileResponse::class, $ response ->baseResponse );
49+ }
50+
51+ /** @test */
52+ public function it_can_return_a_pdf_file ()
53+ {
54+ $ response = $ this ->get ('users?action=pdf ' );
55+
56+ $ this ->assertInstanceOf (Response::class, $ response ->baseResponse );
57+ }
58+
2459 protected function setUp (): void
2560 {
2661 parent ::setUp ();
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public function query(User $user): Builder
2323 return $ user ->newQuery ()->select ('* ' );
2424 }
2525
26- public function html ()
26+ public function html (): \ Yajra \ DataTables \ Html \ Builder
2727 {
2828 return $ this ->builder ()
2929 ->setTableId ('users-table ' )
Original file line number Diff line number Diff line change 22
33namespace Yajra \DataTables \Buttons \Tests ;
44
5+ use Barryvdh \Snappy \ServiceProvider ;
56use Illuminate \Database \Schema \Blueprint ;
67use Illuminate \Testing \TestResponse ;
78use Orchestra \Testbench \TestCase as BaseTestCase ;
@@ -110,6 +111,7 @@ protected function getPackageProviders($app): array
110111 DataTablesServiceProvider::class,
111112 ButtonsServiceProvider::class,
112113 HtmlServiceProvider::class,
114+ ServiceProvider::class,
113115 ];
114116 }
115117
Original file line number Diff line number Diff line change 1+ {{ $dataTable -> table () } }
2+
3+ {{ $dataTable -> scripts () } }
You can’t perform that action at this time.
0 commit comments