Simply add a new command like $schedule->command('command:name')->hourly(); inside schedule function.
Example of test
<?php
class YourCommandTest extends TestCase
{
public function testExample()
{
Artisan::call('your_command', [
'command_parameter_1' => 'value1',
'command_parameter_2' => 'value2',
]);
// If you need result of console output
$resultAsText = Artisan::output();
$this->assertTrue(true);
}
}
It is much easier now:
<?php
class YourCommandTest extends TestCase
{
public function testExample()
{
$this->artisan('command', ['param' => 'value']);
}
}
Maybe useful for someone
Artisan command Test Cases in Laravel 5.7
public function test_console_command()
{
$this->artisan('your_command')
->expectsQuestion('What is your name?', 'Ajay Makwana')
->expectsQuestion('Which language do you program in?', 'PHP')
->expectsOutput('Your name is Ajay Makwana and you program in PHP.')
->assertExitCode(0);
}
https://laravel-news.com/testing-artisan-commands-in-laravel-5-7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With