Level 74
Can you somehow disable timestamps for the model when running a test?
1 like
Summer Sale! All accounts are 50% off this week.
I am writing some tests and need to seed some entries in the database that is a few days old. Sadly this seems to be hard for some reason. I want to overwrite the created_at timestamp but I cannot seem to find a way of doing so with factories.
I have tried
Date::now() for timestamps.['created_at' => now()->subDays(2)] to the factory, which also does not work.Any ideas?
Ah! Seems it works with the built in timetravel og laravel
$this->travelTo(now()->subDays(2));
Please or to participate in this conversation.