You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I want to say thanks for the library, it has been really helpful in our project 👏
I was wondering if there is a way to change the created_at for testing?
When you are testing sometimes is useful to create a revision at a certain point in time (e.g in the past). In my case, I have a query that relies on the created_at. And I want to create multiple revisions on different days in the past.
I tried to do Carbon::setTestNow(Carbon::create(2020, 10, 15)); (Carbon setTestNow) but this doesn't work, because the created_at (also updated_at) properties are created with new \DateTime().
Is it possible to change new \DateTime() with a Carbon::now() so we can use setTestNow for testing? (I can provide a PR)
Or you know some way to accomplish what I want?
I know that I can create the revisions manually but then when you change the model, that creates more revisions and that affects the tests and also I believe with setTestNow the tests are more idiomatic.
Thanks for your help.
The text was updated successfully, but these errors were encountered:
First, I want to say thanks for the library, it has been really helpful in our project 👏
I was wondering if there is a way to change the
created_at
for testing?When you are testing sometimes is useful to create a revision at a certain point in time (e.g in the past). In my case, I have a query that relies on the created_at. And I want to create multiple revisions on different days in the past.
I tried to do
Carbon::setTestNow(Carbon::create(2020, 10, 15));
(Carbon setTestNow) but this doesn't work, because thecreated_at
(alsoupdated_at
) properties are created withnew \DateTime()
.Is it possible to change
new \DateTime()
with aCarbon::now()
so we can usesetTestNow
for testing? (I can provide a PR)Or you know some way to accomplish what I want?
I know that I can create the revisions manually but then when you change the model, that creates more revisions and that affects the tests and also I believe with
setTestNow
the tests are more idiomatic.Thanks for your help.
The text was updated successfully, but these errors were encountered: