Commit c084a2c5 authored by Manan Jadhav's avatar Manan Jadhav

use Carbon::now for fresh timestamps

parent 78d7cbdd
...@@ -118,7 +118,7 @@ abstract class Model extends BaseModel ...@@ -118,7 +118,7 @@ abstract class Model extends BaseModel
*/ */
public function freshTimestamp() public function freshTimestamp()
{ {
return new UTCDateTime(time() * 1000); return new UTCDateTime(Carbon::now());
} }
/** /**
......
...@@ -434,6 +434,16 @@ class ModelTest extends TestCase ...@@ -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']); $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->assertEquals($item->created_at, $fakeDate);
}
public function testIdAttribute(): void public function testIdAttribute(): void
{ {
/** @var User $user */ /** @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