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()
118
118
*/
119
119
public function freshTimestamp ()
120
120
{
121
- return new UTCDateTime (time () * 1000 );
121
+ return new UTCDateTime (Carbon:: now () );
122
122
}
123
123
124
124
/**
Original file line number Diff line number Diff line change @@ -434,6 +434,16 @@ public function testDates(): void
434
434
$ this ->assertEquals ((string ) $ user ->getAttribute ('entry.date ' )->format ('Y-m-d H:i:s ' ), $ data ['entry ' ]['date ' ]);
435
435
}
436
436
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
+
437
447
public function testIdAttribute (): void
438
448
{
439
449
/** @var User $user */
You can’t perform that action at this time.
0 commit comments