-
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] Optimize commands registration
- Loading branch information
Showing
5 changed files
with
134 additions
and
14 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
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
37 changes: 37 additions & 0 deletions
37
tests/Integration/Foundation/Console/OptimizeClearCommandTest.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,37 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Foundation\Console; | ||
|
||
use Illuminate\Foundation\Console\ClosureCommand; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Tests\Integration\Generators\TestCase; | ||
|
||
class OptimizeClearCommandTest extends TestCase | ||
{ | ||
protected function getPackageProviders($app): array | ||
{ | ||
return [TestServiceProvider::class]; | ||
} | ||
|
||
public function testCanListenToOptimizingEvent(): void | ||
{ | ||
$this->artisan('optimize:clear') | ||
->assertSuccessful() | ||
->expectsOutputToContain('my package'); | ||
} | ||
} | ||
|
||
class TestServiceProvider extends ServiceProvider | ||
{ | ||
public function boot(): void | ||
{ | ||
$this->commands([ | ||
new ClosureCommand('my_package:clear', fn () => 0), | ||
]); | ||
|
||
$this->registerOptimizeCommands( | ||
key: 'my package', | ||
optimizeClear: 'my_package:clear', | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/Integration/Foundation/Console/OptimizeCommandTest.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,37 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Foundation\Console; | ||
|
||
use Illuminate\Foundation\Console\ClosureCommand; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Tests\Integration\Generators\TestCase; | ||
|
||
class OptimizeCommandTest extends TestCase | ||
{ | ||
protected function getPackageProviders($app): array | ||
{ | ||
return [TestServiceProvider::class]; | ||
} | ||
|
||
public function testCanListenToOptimizingEvent(): void | ||
{ | ||
$this->artisan('optimize') | ||
->assertSuccessful() | ||
->expectsOutputToContain('my package'); | ||
} | ||
} | ||
|
||
class TestServiceProvider extends ServiceProvider | ||
{ | ||
public function boot(): void | ||
{ | ||
$this->commands([ | ||
new ClosureCommand('my_package:cache', fn () => 0), | ||
]); | ||
|
||
$this->registerOptimizeCommands( | ||
key: 'my package', | ||
optimize: 'my_package:cache', | ||
); | ||
} | ||
} |