Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Clock] Align MockClock::sleep() behavior with NativeClock for negative values#62346

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
yoeunes wants to merge1 commit intosymfony:6.4
base:6.4
Choose a base branch
Loading
fromyoeunes:mockclock-negative-sleep

Conversation

@yoeunes
Copy link
Contributor

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues-
LicenseMIT

This PR fixes a behavioral inconsistency betweenNativeClock andMockClock when handling negative sleep durations.

The Problem:

  • NativeClock::sleep(-10): Silently does nothing. The time does not change.
  • MockClock::sleep(-10):Travels backward in time by 10 seconds.

This inconsistency can lead to unreliable tests, as the mock does not accurately represent the real implementation's behavior for this edge case.

The Fix:
This fix adds a guard clause toMockClock::sleep() to ignore any duration less than or equal to zero, perfectly matching the behavior ofNativeClock.

Before (The Bug):

$clock =newMockClock('2000-01-01 12:00:00');$clock->sleep(-10);// $clock->now() is '2000-01-01 11:59:50'

After (The Fix):

$clock =newMockClock('2000-01-01 12:00:00');$clock->sleep(-10);// $clock->now() is '2000-01-01 12:00:00'

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

2 participants

@yoeunes@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp