/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php
95 строк
3 KB
Lucas Michot
Use Carbon::now() and Date::now() instead of now() helper (#59252)
17 мар 2026, 23:24
Не верифицирован
17 мар 2026, 23:24
62df898
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Console\Scheduling; use Illuminate\Console\Application; use Illuminate\Console\Command; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\ScheduleTestCommand; use Illuminate\Support\Carbon; use Orchestra\Testbench\TestCase; class ScheduleTestCommandTest extends TestCase { public $schedule; protected function setUp(): void { parent::setUp(); Carbon::setTestNow(Carbon::now()->startOfYear()); $this->schedule = $this->app->make(Schedule::class); } public function testRunNoDefinedCommands() { $this->artisan(ScheduleTestCommand::class) ->assertSuccessful() ->expectsOutputToContain('No scheduled commands have been defined.'); } public function testRunNoMatchingCommand() { $this->schedule->command(BarCommandStub::class); $this->artisan(ScheduleTestCommand::class, ['--name' => 'missing:command']) ->assertSuccessful() ->expectsOutputToContain('No matching scheduled command found.'); } public function testRunUsingNameOption() { $this->schedule->command(BarCommandStub::class)->name('bar-command'); $this->schedule->job(BarJobStub::class); $this->schedule->call(fn () => true)->name('callback'); $expectedOutput = windows_os() ? 'Running ["artisan" bar:command]' : "Running ['artisan' bar:command]"; $this->artisan(ScheduleTestCommand::class, ['--name' => 'bar:command']) ->assertSuccessful() ->expectsOutputToContain($expectedOutput); $this->artisan(ScheduleTestCommand::class, ['--name' => BarJobStub::class]) ->assertSuccessful() ->expectsOutputToContain(sprintf('Running [%s]', BarJobStub::class)); $this->artisan(ScheduleTestCommand::class, ['--name' => 'callback']) ->assertSuccessful() ->expectsOutputToContain('Running [callback]'); } public function testRunUsingChoices() { $this->schedule->command(BarCommandStub::class)->name('bar-command'); $this->schedule->job(BarJobStub::class); $this->schedule->call(fn () => true)->name('callback'); $this->artisan(ScheduleTestCommand::class) ->assertSuccessful() ->expectsChoice( 'Which command would you like to run?', 'callback', [Application::formatCommandString('bar:command'), BarJobStub::class, 'callback'], true ) ->expectsOutputToContain('Running [callback]'); } } class BarCommandStub extends Command { protected $signature = 'bar:command'; protected $description = 'This is the description of the command.'; } class BarJobStub { public function __invoke() { // .. } }