File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
src/Jenssegers/Mongodb/Eloquent Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ public function getDateFormat()
118118 */
119119 public function freshTimestamp ()
120120 {
121- return new UTCDateTime (time () * 1000 );
121+ return new UTCDateTime (Carbon:: now () );
122122 }
123123
124124 /**
Original file line number Diff line number Diff line change @@ -434,6 +434,16 @@ public function testDates(): void
434434 $ this ->assertEquals ((string ) $ user ->getAttribute ('entry.date ' )->format ('Y-m-d H:i:s ' ), $ data ['entry ' ]['date ' ]);
435435 }
436436
437+ public function testCarbonDateMockingWorks ()
438+ {
439+ $ fakeDate = \Carbon \Carbon::createFromDate (2000 , 01 , 01 );
440+
441+ Carbon::setTestNow ($ fakeDate );
442+ $ item = Item::create (['name ' => 'sword ' ]);
443+
444+ $ this ->assertLessThan (1 , $ fakeDate ->diffInSeconds ($ item ->created_at ));
445+ }
446+
437447 public function testIdAttribute (): void
438448 {
439449 /** @var User $user */
You can’t perform that action at this time.
0 commit comments