From e3b744cc2f5bfbd0620c2ba17c452b0a7bbc2a9f Mon Sep 17 00:00:00 2001 From: yaozm Date: Wed, 30 Aug 2023 16:29:31 +0800 Subject: [PATCH] test(OutputTest): Update console output functionality - Update OutputTest to assert the exit code - Improve code readability --- tests/Commands/ClearCommandTest.php | 3 ++- tests/Feature/OutputTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Commands/ClearCommandTest.php b/tests/Commands/ClearCommandTest.php index bb8ce9f..ea210a7 100644 --- a/tests/Commands/ClearCommandTest.php +++ b/tests/Commands/ClearCommandTest.php @@ -14,6 +14,7 @@ use Guanguans\LaravelSoar\Commands\ClearCommand; use Guanguans\LaravelSoar\Facades\Soar; +use Symfony\Component\Console\Command\Command; use function Pest\Laravel\artisan; @@ -22,6 +23,6 @@ $logFile = Soar::getLogOutput(\dirname(Soar::getSoarPath()).\DIRECTORY_SEPARATOR.'soar.log'); expect($logFile)->toBeFile(); - artisan(ClearCommand::class)->expectsOutput('Clearing Soar log file...')->assertSuccessful(); + artisan(ClearCommand::class)->expectsOutput('Clearing Soar log file...')->assertExitCode(Command::SUCCESS); expect($logFile)->not->toBeFile(); })->group(__DIR__, __FILE__); diff --git a/tests/Feature/OutputTest.php b/tests/Feature/OutputTest.php index 472feaf..e63604c 100644 --- a/tests/Feature/OutputTest.php +++ b/tests/Feature/OutputTest.php @@ -15,6 +15,7 @@ use Guanguans\LaravelSoar\OutputManager; use Guanguans\LaravelSoar\Outputs\JsonOutput; use Guanguans\LaravelSoar\Outputs\SoarBarOutput; +use Symfony\Component\Console\Command\Command; beforeEach(function (): void { $this->see = [ @@ -29,7 +30,7 @@ it('can outputs console', function (): void { $this->artisan('outputs') - ->assertSuccessful() + ->assertExitCode(Command::SUCCESS) ->expectsOutput(OutputManager::class); })->group(__DIR__, __FILE__);