Skip to content

Fix usages from datetime to carbon - #447

Open
matthewfarrugia wants to merge 2 commits into
VentureCraft:masterfrom
matthewfarrugia:fix-datetime-to-carbon
Open

Fix usages from datetime to carbon#447
matthewfarrugia wants to merge 2 commits into
VentureCraft:masterfrom
matthewfarrugia:fix-datetime-to-carbon

Conversation

@matthewfarrugia

Copy link
Copy Markdown

Issue
#384

Caller code will have functionality around revision and therefore are integration tested.
However since this repo currently uses DateTime making changes to models with often cause the created_at dates on the revisions to be exactly the same time - this means revision order is incorrect and tests will intermittently fail due to $model->revisionHistory->latest() having an indeterminate order.

Fix
The fix is to use Carbon::now instead of DateTime (matching the instance type returned by $model->created_at) - using Carbon also allows for faking in tests using Carbon::setTestNow() - the now time can be changed in order to simulate time between revisions, guaranteeing a reproducible order.

…on::setTestNow() to properly test implementations and matches return value type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant