Skip to content

test: fix DateTimeImmutable plus one year calls#307

Merged
phil-davis merged 1 commit into
mainfrom
adjust-DateTimeImmutable-tests
Jun 8, 2026
Merged

test: fix DateTimeImmutable plus one year calls#307
phil-davis merged 1 commit into
mainfrom
adjust-DateTimeImmutable-tests

Conversation

@phil-davis

@phil-davis phil-davis commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Some calls were:

new \DateTimeImmutable(date('Y', strtotime('+1 year')))

With just the 'Y' format it gets '2027'. and date('2027') returns 20:27 of today. And so if the test is run before 20:27 then the date is in the future, and the test passes. But if the test is run after 20:27 and before midnight, it will fail because the expiration date requested is in the past.

Actually we can pass '+1 year' directly to DateTimeImmutable and avoid messing about with a date format in the middle. So I changed all '+1 year' usages in tests to do that.

@kw-security

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@phil-davis

Copy link
Copy Markdown
Contributor Author

This should fix the “intermittent” test failures like in #306 last night.

@phil-davis phil-davis merged commit bbc49d7 into main Jun 8, 2026
14 of 15 checks passed
@phil-davis phil-davis deleted the adjust-DateTimeImmutable-tests branch June 8, 2026 03:47
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.

3 participants