-
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.
[11.x] Simplify
ApplicationBuilder::withSchedule()
(#50765)
* Simplify `ApplicationBuilder::withSchedule()` Signed-off-by: Mior Muhammad Zaki <[email protected]> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
5daf210
commit 5c0ad50
Showing
3 changed files
with
42 additions
and
10 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
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
41 changes: 41 additions & 0 deletions
41
tests/Integration/Foundation/Configuration/WithScheduleTest.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,41 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Foundation\Configuration; | ||
|
||
use Illuminate\Console\Scheduling\ScheduleListCommand; | ||
use Illuminate\Foundation\Application; | ||
use Illuminate\Support\Carbon; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class WithScheduleTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Carbon::setTestNow('2023-01-01'); | ||
ScheduleListCommand::resolveTerminalWidthUsing(fn () => 80); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
ScheduleListCommand::resolveTerminalWidthUsing(null); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
protected function resolveApplication() | ||
{ | ||
return Application::configure(static::applicationBasePath()) | ||
->withSchedule(function ($schedule) { | ||
$schedule->command('schedule:clear-cache')->everyMinute(); | ||
})->create(); | ||
} | ||
|
||
public function testDisplaySchedule() | ||
{ | ||
$this->artisan(ScheduleListCommand::class) | ||
->assertSuccessful() | ||
->expectsOutputToContain(' * * * * * php artisan schedule:clear-cache'); | ||
} | ||
} |