Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Exactly match scheduled command --name in schedule:test #41528

Merged
merged 3 commits into from
Mar 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Illuminate/Console/Scheduling/ScheduleTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Illuminate\Console\Scheduling;

use Illuminate\Console\Application;
use Illuminate\Console\Command;
use Illuminate\Support\Str;

class ScheduleTestCommand extends Command
{
Expand Down Expand Up @@ -51,7 +51,11 @@ public function handle(Schedule $schedule)
}

if (! empty($name = $this->option('name'))) {
$matches = array_filter($commandNames, fn ($commandName) => Str::endsWith($commandName, $name));
$commandBinary = Application::phpBinary().' '.Application::artisanBinary();

$matches = array_filter($commandNames, function ($commandName) use ($commandBinary, $name) {
return trim(str_replace($commandBinary, '', $commandName)) === $name;
});

if (count($matches) !== 1) {
return $this->error('No matching scheduled command found.');
Expand Down