Fix for issues with closure-based scheduled commands in schedule:test #47862
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 pull request addresses two issues related to the
schedule:test
command when dealing with multiple closure-based scheduled commands.Issue 1: Incorrectly selecting scheduled closures by index number
php artisan schedule:test
command allowed users to select a task by its index number, but the task selection logic was based on the task name generated by theschedule:test
command, causing all closure-based tasks to have the same name.Issue 2: Incorrect message when using the
--name
option with multiple matching commandsphp artisan schedule:test --name <name>
, the returned message was "No matching scheduled command found," even if multiple commands with the same name existed. This was misleading.These changes ensure that the
schedule:test
command works correctly with closure-based scheduled commands.I have thoroughly tested these changes on the provided reproduction repository on the attached issue, and all scheduled closures are now correctly executed based on the user's input. Additionally, the
--name
option now works as intended, providing choices when multiple matching commands exist.