Closed
Description
I ran the UseComponentPropertyWithinCommandsRector and the tests for my commands failed.
I have built a basic test case, which uses PHP 8.2 and PHPUnit 11.5.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class MyCommand extends Command
{
protected $signature = 'my-command';
public function handle(): int
{
$this->info('Info Finished.');
$this->components->info('Components Finished.');
return Command::SUCCESS;
}
}
And the test…
<?php
declare(strict_types=1);
namespace Tests\Feature\Commands;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
#[Group('command')]
final class MyCommandTest extends TestCase
{
#[Test]
public function expectOutput(): void
{
$this->artisan('my-command')
->expectsOutput('Info Finished.')
->expectsOutput('Components Finished.')
->assertSuccessful();
}
}
Gives the following error;
1) Tests\Feature\Commands\MyCommandTest::expectOutput
Output "Components Finished." was not printed.
Metadata
Metadata
Assignees
Labels
No labels