Unverified Commit 811cb3d0 authored by Jens Segers's avatar Jens Segers Committed by GitHub

Merge pull request #1870 from CurosMJ/fix-fresh-timestamp

Use Carbon::now() for fresh timestamps so that Carbon's time mocking works
parents 87880c03 9a5b1bd2
......@@ -118,7 +118,7 @@ abstract class Model extends BaseModel
*/
public function freshTimestamp()
{
return new UTCDateTime(time() * 1000);
return new UTCDateTime(Carbon::now());
}
/**
......
......@@ -434,6 +434,16 @@ class ModelTest extends TestCase
$this->assertEquals((string) $user->getAttribute('entry.date')->format('Y-m-d H:i:s'), $data['entry']['date']);
}
public function testCarbonDateMockingWorks()
{
$fakeDate = \Carbon\Carbon::createFromDate(2000, 01, 01);
Carbon::setTestNow($fakeDate);
$item = Item::create(['name' => 'sword']);
$this->assertLessThan(1, $fakeDate->diffInSeconds($item->created_at));
}
public function testIdAttribute(): void
{
/** @var User $user */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment