Handle non-numeric values in selected filter for Country API and add corresponding tests

- 🔧 Refactor `CountryController` to safely process non-numeric values in `selected` query parameter using `array_filter`.
- 🧪 Add feature test to ensure API does not crash when `selected` includes non-numeric codes.
This commit is contained in:
HolgerHatGarKeineNode
2026-06-17 09:56:25 +02:00
parent a051188907
commit 276016eed7
2 changed files with 19 additions and 4 deletions
@@ -0,0 +1,13 @@
<?php
use App\Models\Country;
it('does not crash when selected contains non-numeric codes', function () {
Country::factory()->create(['code' => 'CH']);
$response = $this->getJson('/api/countries?'.http_build_query([
'selected' => ['CH', 'de', '1'],
]));
$response->assertSuccessful();
});