mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-05-21 09:05:36 +00:00
e3f8c4c232
- ✅ Added detection logic for `MissingFileUploadsTraitException` to prevent 500 errors. - 🛠️ Updated exception handling to return a 400 response for these scenarios. - 🔇 Suppressed logging of `MissingFileUploadsTraitException` to reduce noise. - ✅ Added tests to verify 400 responses and absence of log entries.
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Livewire\Component;
|
|
use Livewire\Features\SupportFileUploads\MissingFileUploadsTraitException;
|
|
|
|
function throwMissingFileUploadsTraitException(): never
|
|
{
|
|
$component = new class extends Component
|
|
{
|
|
public function getName(): string
|
|
{
|
|
return 'language.selector';
|
|
}
|
|
|
|
public function render(): string
|
|
{
|
|
return '<div></div>';
|
|
}
|
|
};
|
|
|
|
throw new MissingFileUploadsTraitException($component);
|
|
}
|
|
|
|
it('returns 400 for MissingFileUploadsTraitException instead of 500', function () {
|
|
Route::get('/_test/missing-file-uploads-trait', function () {
|
|
throwMissingFileUploadsTraitException();
|
|
});
|
|
|
|
$response = $this->get('/_test/missing-file-uploads-trait');
|
|
|
|
expect($response->status())->toBe(400);
|
|
});
|
|
|
|
it('does not report MissingFileUploadsTraitException to the logs', function () {
|
|
Log::spy();
|
|
|
|
Route::get('/_test/missing-file-uploads-trait-log', function () {
|
|
throwMissingFileUploadsTraitException();
|
|
});
|
|
|
|
$this->get('/_test/missing-file-uploads-trait-log')
|
|
->assertStatus(400);
|
|
|
|
Log::shouldNotHaveReceived('error');
|
|
Log::shouldNotHaveReceived('critical');
|
|
Log::shouldNotHaveReceived('emergency');
|
|
});
|