/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Console/CommandManualFailTest.php
71 строка
2 KB
Lucas Michot
[13.x] Simplify most of the exceptions expectations (#61049)
05 авг 2026, 18:34
Не верифицирован
05 авг 2026, 18:34
910cd94
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Console; use Illuminate\Console\Application as Artisan; use Illuminate\Console\Command; use Illuminate\Console\ManuallyFailedException; use Orchestra\Testbench\TestCase; class CommandManualFailTest extends TestCase { protected function setUp(): void { Artisan::starting(function ($artisan) { $artisan->resolveCommands([ FailingCommandStub::class, ]); }); parent::setUp(); } public function testFailArtisanCommandManually(): void { $this->artisan('app:fail')->assertFailed(); } public function testCreatesAnExceptionFromString(): void { $this->expectExceptionObject(new ManuallyFailedException('Whoops!')); $command = new Command; $command->fail('Whoops!'); } public function testCreatesAnExceptionFromNull(): void { $this->expectExceptionObject(new ManuallyFailedException('Command failed manually.')); $command = new Command; $command->fail(); } public function testThrowsTheOriginalThrowableInstance(): void { try { $command = new Command; $command->fail($original = new \RuntimeException('Something went wrong.')); $this->fail('Command::fail() method must throw the original throwable instance.'); } catch (\Throwable $e) { $this->assertSame($original, $e); } } } class FailingCommandStub extends Command { protected $signature = 'app:fail'; public function handle() { $this->trigger_failure(); // This should never be reached. return static::SUCCESS; } protected function trigger_failure() { $this->fail('Whoops!'); } }