diff --git a/src/Console/Scheduling/Schedule.php b/src/Console/Scheduling/Schedule.php index 01085a6..d81d9bf 100644 --- a/src/Console/Scheduling/Schedule.php +++ b/src/Console/Scheduling/Schedule.php @@ -43,7 +43,7 @@ private function dispatch($task) $command = $task->command; $event = $this->schedule->command( $command, - $task->getArguments() + $task->getOptions() + array_values($task->getArguments()) + $task->getOptions() ); } $event->cron($task->expression); diff --git a/tests/Feature/ScheduleCommandTest.php b/tests/Feature/ScheduleCommandTest.php index 1cbda1d..d7f9370 100644 --- a/tests/Feature/ScheduleCommandTest.php +++ b/tests/Feature/ScheduleCommandTest.php @@ -52,7 +52,10 @@ public function testCommandWithRequiredArgument() $events->each(function (\Illuminate\Console\Scheduling\Event $event) use ($task) { // This example is for hourly commands. $this->assertEquals($task->expression, $event->expression); - $this->assertStringEndsWith("phpunit:test argument='this is a argument'", $event->command); + $this->assertStringEndsWith( + "phpunit:test 'this is a argument'", + $event->command + ); }); } @@ -67,7 +70,7 @@ public function testCommandWithOptionalArgument() 'type' => 'string' ], 'optionalArgument' => [ - 'value' => 'this is a optional argument', + 'value' => 'optional argument', 'type' => 'string' ] ] @@ -75,18 +78,26 @@ public function testCommandWithOptionalArgument() /** @var \Illuminate\Console\Scheduling\Schedule $schedule */ $schedule = app()->make(\Illuminate\Console\Scheduling\Schedule::class); - $events = collect($schedule->events())->filter(function (\Illuminate\Console\Scheduling\Event $event) use ($task) { - return stripos($event->command, $task->command); - }); + $events = collect($schedule->events()) + ->filter( + function (\Illuminate\Console\Scheduling\Event $event) use ($task) { + return stripos($event->command, $task->command); + } + ); if ($events->count() == 0) { $this->fail('No events found'); } - $events->each(function (\Illuminate\Console\Scheduling\Event $event) use ($task) { - // This example is for hourly commands. - $this->assertEquals($task->expression, $event->expression); - $this->assertStringEndsWith("phpunit:test argument='this is a argument' optionalArgument='this is a optional argument'", $event->command); - }); + $events->each( + function (\Illuminate\Console\Scheduling\Event $event) use ($task) { + // This example is for hourly commands. + $this->assertEquals($task->expression, $event->expression); + $this->assertStringEndsWith( + "phpunit:test 'this is a argument' 'optional argument'", + $event->command + ); + } + ); } } diff --git a/tests/Unit/ScheduleCommandsTest.php b/tests/Unit/ScheduleCommandsTest.php index fce2837..3544ffa 100644 --- a/tests/Unit/ScheduleCommandsTest.php +++ b/tests/Unit/ScheduleCommandsTest.php @@ -64,7 +64,7 @@ public function testRunInspireWithArguments() $this->mock(\Illuminate\Console\Scheduling\Schedule::class, function (Mockery\MockInterface $mock) { $mock->shouldReceive('command') ->once() - ->with('inspire', ['test' => '1']) + ->with('inspire', ['1']) ->andReturn($this->event); });