@@ -9,6 +9,7 @@ public function tearDown()
99 m::close ();
1010
1111 Illuminate \Database \Eloquent \Model::unsetEventDispatcher ();
12+ Carbon \Carbon::resetToStringFormat ();
1213 }
1314
1415
@@ -470,6 +471,38 @@ public function testToArray()
470471 }
471472
472473
474+ public function testToArrayIncludesDefaultFormattedTimestamps ()
475+ {
476+ $ model = new EloquentDateModelStub ;
477+ $ model ->setRawAttributes (array (
478+ 'created_at ' => '2012-12-04 ' ,
479+ 'updated_at ' => '2012-12-05 ' ,
480+ ));
481+
482+ $ array = $ model ->toArray ();
483+
484+ $ this ->assertEquals ('2012-12-04 00:00:00 ' , $ array ['created_at ' ]);
485+ $ this ->assertEquals ('2012-12-05 00:00:00 ' , $ array ['updated_at ' ]);
486+ }
487+
488+
489+ public function testToArrayIncludesCustomFormattedTimestamps ()
490+ {
491+ Carbon \Carbon::setToStringFormat ('d-m-y ' );
492+
493+ $ model = new EloquentDateModelStub ;
494+ $ model ->setRawAttributes (array (
495+ 'created_at ' => '2012-12-04 ' ,
496+ 'updated_at ' => '2012-12-05 ' ,
497+ ));
498+
499+ $ array = $ model ->toArray ();
500+
501+ $ this ->assertEquals ('04-12-12 ' , $ array ['created_at ' ]);
502+ $ this ->assertEquals ('05-12-12 ' , $ array ['updated_at ' ]);
503+ }
504+
505+
473506 public function testVisibleCreatesArrayWhitelist ()
474507 {
475508 $ model = new EloquentModelStub ;
0 commit comments