Skip to content
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

withTestNow leaves the effect of setTestNow in place if the closure throws an exception #2561

Closed
crhg opened this issue Mar 10, 2022 · 0 comments · Fixed by #2562
Closed
Labels
Milestone

Comments

@crhg
Copy link
Contributor

crhg commented Mar 10, 2022

Hello,

I encountered an issue with the following code:

try {
    Carbon::withTestNow(
        '1989-02-15 00:00:00',
        function () {
            throw new Exception();
        }
    );
} catch (Exception $e) {
    printf("%s\n", Carbon::now());
}

Carbon version: 2.57.0
PHP version: 8.0.8

I expected to get:

(current date and time)

But I actually get:

1989-02-15 00:00:00

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants