Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ protected function commandIsolationMutex()
*/
protected function resolveCommand($command)
{
if (! class_exists($command)) {
return $this->getApplication()->find($command);
}
if (is_string($command)) {
if (! class_exists($command)) {
return $this->getApplication()->find($command);
}

$command = $this->laravel->make($command);
$command = $this->laravel->make($command);
}

if ($command instanceof SymfonyCommand) {
$command->setApplication($this->getApplication());
Expand Down
38 changes: 38 additions & 0 deletions tests/Integration/Console/CallCommandsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Illuminate\Tests\Integration\Console;

use Illuminate\Foundation\Console\ViewClearCommand;
use Illuminate\Support\Facades\Artisan;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\TestWith;

class CallCommandsTest extends TestCase
{
protected function setUp(): void
{
$this->afterApplicationCreated(function () {
Artisan::command('test:a', function () {
$this->call('view:clear');
});

Artisan::command('test:b', function () {
$this->call(ViewClearCommand::class);
});

Artisan::command('test:c', function () {
$this->call($this->laravel->make(ViewClearCommand::class));
});
});

parent::setUp();
}

#[TestWith(['test:a'])]
#[TestWith(['test:b'])]
#[TestWith(['test:c'])]
public function testItCanCallCommands(string $command)
{
$this->artisan($command)->assertSuccessful();
}
}