-
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.
[5.6] Execute an Artisan command using either its name or class (#23764)
* [5.6] Execute an Artisan command using either it's name or class * Add assertions * Use is_subclass_of()
- Loading branch information
1 parent
f44c3e7
commit f58c004
Showing
2 changed files
with
59 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Console; | ||
|
||
use Illuminate\Console\Command; | ||
use Orchestra\Testbench\TestCase; | ||
use Illuminate\Contracts\Console\Kernel; | ||
|
||
class ConsoleApplicationTest extends TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->app[Kernel::class]->registerCommand(new FooCommandStub); | ||
} | ||
|
||
public function test_artisan_call_using_command_name() | ||
{ | ||
$exitCode = $this->artisan('foo:bar', [ | ||
'id' => 1, | ||
]); | ||
|
||
$this->assertEquals($exitCode, 0); | ||
} | ||
|
||
public function test_artisan_call_using_command_class() | ||
{ | ||
$exitCode = $this->artisan(FooCommandStub::class, [ | ||
'id' => 1, | ||
]); | ||
|
||
$this->assertEquals($exitCode, 0); | ||
} | ||
|
||
/** | ||
* @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException | ||
*/ | ||
public function test_artisan_call_invalid_command_name() | ||
{ | ||
$this->artisan('foo:bars'); | ||
} | ||
} | ||
|
||
class FooCommandStub extends Command | ||
{ | ||
protected $signature = 'foo:bar {id}'; | ||
|
||
public function handle() | ||
{ | ||
// | ||
} | ||
} |