[8.x] Added new assertDispatchedSync methods to BusFake #37350
Merged
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.
Added new
assertDispatchedSync
methods to the Bus Fake, following the pattern ofassertDispatched
andassertDispatchedAfterResponse
.This allows applications to assert that a given command was explicitly sent to the
sync
driver. This is useful where applications may want to conditionally handle a job synchronously in the current request/thread, rather than sending it to the application's default queue driver; And of course, assert that such logic executed correctly:Since this PR includes quite a few new lines (222 additions), it's understandable if this is too much change for a minor update. If that's the case, please feel free to let me know and I'll suggest over on the master branch for 9.x.
Cheers!
Additions to the Public API of
BusFake
These methods follow the existing patterns of
assertDispatched
andassertDispatchedAfterResponse
:+ assertDispatchedSync($command, $callback = null)
+ assertDispatchedSyncTimes($command, $times = 1)
+ assertNotDispatchedSync($command, $callback = null)
+ dispatchedSync(string $command, $callback = null)
+ hasDispatchedSync($command)
6 additional tests have been added to
Illuminate\Tests\Support\SupportTestingBusFakeTest
to test these above new methods.No Breaking Changes
Existing applications that dispatch jobs using
dispatchSync
and test that such jobs were dispatched usingassertDispatched
,assertDispatchedTimes
orassertNotDispatched
will not be affected by this change. This is because these assertion methods have been updated in this PR to check against thedispatchedSync
method.