Skip to content

Commit 2d65578

Browse files
authored
合并拉取请求 #46
issue-45-_BUG_Guanguans_LaravelExceptionNotify_Commands_TestCommand_析构函数报错
2 parents 5861fec + 80dba37 commit 2d65578

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/Commands/TestCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
use Guanguans\LaravelExceptionNotify\ExceptionNotifyManager;
1616
use Guanguans\LaravelExceptionNotify\Exceptions\RuntimeException;
1717
use Illuminate\Console\Command;
18+
use Illuminate\Console\OutputStyle;
1819
use Illuminate\Support\Arr;
20+
use Symfony\Component\Console\Input\ArgvInput;
21+
use Symfony\Component\Console\Output\ConsoleOutput;
1922

2023
class TestCommand extends Command
2124
{
@@ -27,6 +30,10 @@ class TestCommand extends Command
2730

2831
public function __destruct()
2932
{
33+
if (! $this->output instanceof OutputStyle) {
34+
$this->output = new OutputStyle(new ArgvInput, new ConsoleOutput);
35+
}
36+
3037
if ($this->error) {
3138
$this->output->error($this->error);
3239

tests/Commands/TestCommandTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,9 @@
1212

1313
use Guanguans\LaravelExceptionNotify\Commands\TestCommand;
1414
use Symfony\Component\Console\Command\Command;
15-
use Symfony\Component\Console\Input\ArgvInput;
16-
use Symfony\Component\Console\Output\ConsoleOutput;
17-
use Symfony\Component\Console\Style\SymfonyStyle;
1815

1916
use function Pest\Laravel\artisan;
2017

21-
beforeEach(function (): void {
22-
$this->app->extend(TestCommand::class, function (TestCommand $testCommand) {
23-
if (! $testCommand->getOutput()) {
24-
(function (): void {
25-
$this->output = new SymfonyStyle(new ArgvInput, new ConsoleOutput);
26-
})->call($testCommand);
27-
}
28-
29-
return $testCommand;
30-
});
31-
});
32-
3318
it('can test for exception-notify', function (): void {
3419
config()->set('exception-notify.enabled', false);
3520
artisan(TestCommand::class)->assertExitCode(Command::SUCCESS);

0 commit comments

Comments
 (0)