[8.x] Add scheduler integration tests #39862
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.
This adds two tests for the scheduler. The first tests scheduled callbacks, and the second tests scheduled commands.
Scheduled callbacks are relatively easy to test because they always run in the same process as the scheduler. These tests verify execution order, exception handling, and mutex processing (for
onOneServer
).Scheduled commands are trickier to test because they rely on spawning an external
php artisan ...
process, which is currently not supported in Orchestra Testbench. To work around this issue, we write a customartisan
script that is used for our test. It includes:artisan
script that is modified to account for the location of thetestbench-core/laravel
directory(This file is removed during the tear down phase.)
The command tests work by writing to a log file and then checking that the expected output exists in that file. This means that we can use the full Laravel scheduler (including the call to
php artisan schedule:finish
when running in background) without having to mock or fake anything.