|
19 | 19 | * @see https://github.com/guanguans/laravel-soar |
20 | 20 | */ |
21 | 21 |
|
| 22 | +use Composer\Semver\Comparator; |
22 | 23 | use Guanguans\LaravelSoar\Bootstrapper; |
| 24 | +use Illuminate\Console\Events\CommandFinished; |
| 25 | +use Illuminate\Foundation\Application; |
23 | 26 | use Illuminate\Support\Arr; |
24 | | - |
25 | | -beforeEach(function (): void { |
26 | | - resolve(Bootstrapper::class)->boot(); |
27 | | - |
28 | | - $this->see = collect(Arr::first(Soar::arrayScores('select * from users'))) |
29 | | - ->except(['ID', 'Fingerprint']) |
30 | | - ->keys() |
31 | | - ->push('Summary', 'Basic', 'Backtraces') |
32 | | - ->all(); |
33 | | -}); |
34 | | - |
35 | | -it('can not output soar scores', function (): void { |
36 | | - config()->set('soar.except', ['output:all']); |
37 | | - |
38 | | - $this->artisan('output:all') |
39 | | - // ->expectsOutput(OutputManager::class) |
40 | | - ->expectsOutputToContain(OutputManager::class) |
41 | | - ->assertOk(); |
| 27 | +use Illuminate\Support\Facades\Event; |
| 28 | +use Workbench\App\Support\Utils; |
| 29 | + |
| 30 | +uses(WithConsoleEvents::class) |
| 31 | + ->beforeEach(function (): void { |
| 32 | + resolve(Bootstrapper::class)->boot(); |
| 33 | + |
| 34 | + $this->see = collect(Arr::first(Soar::arrayScores('select * from users'))) |
| 35 | + ->except(['ID', 'Fingerprint']) |
| 36 | + ->keys() |
| 37 | + ->push('Summary', 'Basic', 'Backtraces') |
| 38 | + ->all(); |
| 39 | + }); |
| 40 | + |
| 41 | +it('is a console output example', function (): void { |
| 42 | + Event::fakeFor(function (): void { |
| 43 | + $this->artisan('output:example') |
| 44 | + // ->expectsOutput(Utils::CONSOLE_OUTPUT_PHRASE) |
| 45 | + ->expectsOutputToContain(Utils::CONSOLE_OUTPUT_PHRASE) |
| 46 | + ->assertOk(); |
| 47 | + |
| 48 | + // Event::assertDispatched(CommandFinished::class); |
| 49 | + }); |
42 | 50 | })->group(__DIR__, __FILE__); |
43 | 51 |
|
44 | | -it('can outputs console', function (): void { |
45 | | - $this->artisan('output:all') |
46 | | - // ->expectsOutput(OutputManager::class) |
47 | | - ->expectsOutputToContain(OutputManager::class) |
48 | | - ->assertOk(); |
49 | | -})->group(__DIR__, __FILE__); |
| 52 | +it('is a console output example with console events ', function (): void { |
| 53 | + Event::fakeFor(function (): void { |
| 54 | + $this->artisan('output:example') |
| 55 | + // ->expectsOutput(Utils::CONSOLE_OUTPUT_PHRASE) |
| 56 | + ->expectsOutputToContain(Utils::CONSOLE_OUTPUT_PHRASE) |
| 57 | + ->assertOk(); |
| 58 | + |
| 59 | + Event::assertDispatched(CommandFinished::class); |
| 60 | + }); |
| 61 | +}) |
| 62 | + ->group(__DIR__, __FILE__) |
| 63 | + ->skip(Comparator::lessThan(Application::VERSION, '11.0.0')); |
0 commit comments