File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,26 @@ public function it_can_return_formatted_column_using_closure()
141141 $ this ->assertEquals (Carbon::parse ($ user ->created_at )->format ('Y-m-d ' ), $ data ['created_at_formatted ' ]);
142142 }
143143
144+ /** @test */
145+ public function it_can_return_formatted_column_on_invalid_formatter ()
146+ {
147+ $ crawler = $ this ->call ('GET ' , '/eloquent/formatColumn-fallback ' );
148+
149+ $ crawler ->assertJson ([
150+ 'draw ' => 0 ,
151+ 'recordsTotal ' => 20 ,
152+ 'recordsFiltered ' => 20 ,
153+ ]);
154+
155+ $ user = User::find (1 );
156+ $ data = $ crawler ->json ('data ' )[0 ];
157+
158+ $ this ->assertTrue (isset ($ data ['created_at ' ]));
159+ $ this ->assertTrue (isset ($ data ['created_at_formatted ' ]));
160+
161+ $ this ->assertEquals ($ user ->created_at , $ data ['created_at_formatted ' ]);
162+ }
163+
144164 /** @test */
145165 public function it_accepts_a_relation ()
146166 {
@@ -177,5 +197,11 @@ protected function setUp(): void
177197 ->formatColumn ('created_at ' , fn ($ value , $ row ) => Carbon::parse ($ value )->format ('Y-m-d ' ))
178198 ->toJson ();
179199 });
200+
201+ $ router ->get ('/eloquent/formatColumn-fallback ' , function (DataTables $ dataTable ) {
202+ return $ dataTable ->eloquent (User::query ())
203+ ->formatColumn ('created_at ' , 'InvalidFormatter::class ' )
204+ ->toJson ();
205+ });
180206 }
181207}
You can’t perform that action at this time.
0 commit comments