fix(test): use willReturnCallback and unique service keys in SchedulerWorkerTest (closes #668) - #771
Merged
s2x merged 2 commits intoAug 22, 2026
Conversation
added 2 commits
August 22, 2026 03:10
…rWorkerTest (closes #668) - Replace willReturn(new DateTimeImmutable('+1 second')) with willReturnCallback(fn(\DateTimeImmutable $now): \DateTimeImmutable => $now->modify('+1 second')) in two test methods, fixing the evaluates-once-at-stub-time trap (FAQ-022) - Replace shared 'test_service' key with unique per-test keys ('args_test_service', 'callable_test_service') to prevent static $tickCallbacks cross-test deduplication - Add explicit return type to arrow functions (AddArrowFunctionReturnTypeRector)
s2x
deleted the
refactor/issue-668-schedulerworkertest-willreturn-datetimei
branch
August 22, 2026 01:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #668
Fixes two latent test fragilities in
tests/Worker/SchedulerWorkerTest.php:willReturn(new DateTimeImmutable('+1 second'))evaluates once — the relative string is parsed at stub-configuration time, returning the same fixed absolute date on every call. Replaced withwillReturnCallback(fn(\DateTimeImmutable $now): \DateTimeImmutable => $now->modify('+1 second')), matching the pattern documented in FAQ-022.Shared
test_servicekey causes cross-test deduplication — bothtestScheduleCallbackPassesArgsToDelayandtestScheduleCallbackUsesFirstClassCallableused the same service key, so thestatic $tickCallbacksdedup inscheduleCallback()reused the first test's closure/args for the second test. Replaced with unique per-test keys (args_test_service,callable_test_service), matching the convention already used by the newer tests.Changes
tests/Worker/SchedulerWorkerTest.php: 2 stub replacements + 2 service key renames + arrow function return typesChangelog
Added entry under
[Unreleased] → Fixedin CHANGELOG.md.Proof of Work
docs/proof_of_work/0668-schedulerworkertest-datetime-dedup/— 1 review roundCode Review