-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
ScheduleListCommandTest.php
64 lines (50 loc) · 2.19 KB
/
ScheduleListCommandTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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.';
}