-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.x] Redesign
php artisan schedule:list
Command. (#41445)
* Redesign `php artisan schedule:list` Command. * style: fix * style: fix * fix: Remove `SHELL_VERBOSITY` from env after tests. * formatting * empty satte * adjust wording * Clear `AliasLoader` after the tests. * move test * remove alias clear * delete line * fix: Replace " also (Windows) * style: fixes * Improve RegExp for windows machines. * style: fixes Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
f691533
commit d13c348
Showing
2 changed files
with
185 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/Integration/Console/Scheduling/ScheduleListCommandTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Console\Scheduling; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Console\Scheduling\ScheduleListCommand; | ||
use Illuminate\Support\Carbon; | ||
use Illuminate\Support\ProcessUtils; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class ScheduleListCommandTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Carbon::setTestNow(now()->startOfYear()); | ||
ScheduleListCommand::resolveTerminalWidthUsing(fn () => 80); | ||
|
||
$this->schedule = $this->app->make(Schedule::class); | ||
} | ||
|
||
public function testDisplaySchedule() | ||
{ | ||
$this->schedule->call(fn () => '')->everyMinute(); | ||
$this->schedule->command(FooCommand::class)->quarterly(); | ||
$this->schedule->command('inspire')->twiceDaily(14, 18); | ||
$this->schedule->command('foobar', ['a' => 'b'])->everyMinute(); | ||
|
||
$this->artisan(ScheduleListCommand::class) | ||
->assertSuccessful() | ||
->expectsOutput(' * * * * * ............................ Next Due: 1 minute from now') | ||
->expectsOutput(' 0 0 1 1-12/3 * php artisan foo:command .... Next Due: 3 months from now') | ||
->expectsOutput(' 0 14,18 * * * php artisan inspire ........ Next Due: 14 hours from now') | ||
->expectsOutput(' * * * * * php artisan foobar a='.ProcessUtils::escapeArgument('b').' ... Next Due: 1 minute from now'); | ||
} | ||
|
||
public function testDisplayScheduleInVerboseMode() | ||
{ | ||
$this->schedule->command(FooCommand::class)->everyMinute(); | ||
|
||
$this->artisan(ScheduleListCommand::class, ['-v' => true]) | ||
->assertSuccessful() | ||
->expectsOutputToContain('Next Due: '.now()->setMinutes(1)->format('Y-m-d H:i:s P')) | ||
->expectsOutput(' ⇁ This is the description of the command.'); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
putenv('SHELL_VERBOSITY'); | ||
|
||
ScheduleListCommand::resolveTerminalWidthUsing(null); | ||
} | ||
} | ||
|
||
class FooCommand extends Command | ||
{ | ||
protected $signature = 'foo:command'; | ||
|
||
protected $description = 'This is the description of the command.'; | ||
} |