-
Notifications
You must be signed in to change notification settings - Fork 3
Handle Carbon 3 timestamp parsing and add boundary tests #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
069c041
a51fd9c
d86dba6
842a701
e81d3e8
5d81db8
da79c7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ public function testGetCarbonFromMWTimestamp() { | |
|
|
||
| public function testGetCarbonFromMWTimestampWithInvalidTimestamp() { | ||
| $this->expectException(InvalidFormatException::class); | ||
| $this->expectExceptionMessage('Unable to create Carbon object'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As line 21 is expecting the Exception already, I struggle to see how this check helps us
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just want to lock down the exact error message. a bit redundant, yes... WHat do you think? keep it or remove it? |
||
|
|
||
| $invalidMwTimestamp = 'invalid_timestamp'; | ||
| MWTimestampHelper::getCarbonFromMWTimestamp($invalidMwTimestamp); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit unclear about this part.
createFormFormat, I'm not certain it helps to catch it just so we can throw our own. This could even make it harder to spot the reason for why it failed.CarbonImmutableor an Exception gets thrownSo I think this method could be as simple as just line 19 - if something goes wrong an exception gets thrown as it used to. Is there more context for this additional logic that I'm not aware of?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right to question it, it's an overthinking part from me. My logic is
createFromFormat()may throw a non-instance (null/false), so an extrainstanceofguard prevents type error when returning$carbon.