Optimierung 2.7: Company::scopeSearchByTerm fuer die Admin-Combobox

Die in admin/create und admin/edit identische Inline-Firmensuche
(Volltext-oder-LIKE) inkl. des 2x duplizierten supportsFullTextSearch()-
Treiберchecks in einen Company::scopeSearchByTerm() zentralisiert; beide
Editoren nutzen ihn jetzt (Verhalten unveraendert). Ungenutzte DB-Importe
entfernt. Customer nutzt bereits CustomerCompanyContext (eigene
join-/user-gescopte Query, daher nicht zusammengelegt).

Tests: neuer Scope-Test; volle Suite gruen (799 passed, 1 skipped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-06-19 10:06:54 +00:00
parent 5d6a94902b
commit 28e9064410
4 changed files with 58 additions and 28 deletions

View file

@ -0,0 +1,25 @@
<?php
use App\Models\Company;
test('searchByTerm matches name and slug, ignoring non-matches', function () {
$acme = Company::factory()->create(['name' => 'Acme Industries', 'slug' => 'acme-industries']);
$globex = Company::factory()->create(['name' => 'Globex Corporation', 'slug' => 'globex-corp']);
$results = Company::query()->searchByTerm('Acme')->pluck('id');
expect($results)->toContain($acme->id)
->not->toContain($globex->id);
});
test('searchByTerm returns the query unchanged for a blank term', function () {
Company::factory()->count(3)->create();
expect(Company::query()->searchByTerm('')->count())->toBe(Company::query()->count());
});
test('searchByTerm strips a trailing portal abbreviation from the term', function () {
$company = Company::factory()->create(['name' => 'Musterfirma']);
expect(Company::query()->searchByTerm('Musterfirma (PE)')->pluck('id'))->toContain($company->id);
});