Skip to content

Commit

Permalink
test(OutputTest): Update console output functionality
Browse files Browse the repository at this point in the history
- Update OutputTest to assert the exit code
- Improve code readability
  • Loading branch information
guanguans committed Aug 30, 2023
1 parent 20dd278 commit e3b744c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/Commands/ClearCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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__);
3 changes: 2 additions & 1 deletion tests/Feature/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -29,7 +30,7 @@

it('can outputs console', function (): void {
$this->artisan('outputs')
->assertSuccessful()
->assertExitCode(Command::SUCCESS)
->expectsOutput(OutputManager::class);
})->group(__DIR__, __FILE__);

Expand Down

0 comments on commit e3b744c

Please sign in to comment.