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:
parent
83d2ee659a
commit
86ba6c1a51
4 changed files with 58 additions and 28 deletions
25
tests/Feature/CompanySearchByTermTest.php
Normal file
25
tests/Feature/CompanySearchByTermTest.php
Normal 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);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue