gruene-seele/tests/Feature/IngredientSupplierFilterTest.php
Kevin Adametz 4eb36486b0 Warenwirtschaft: AP-49 — INCI-Lieferanten-Dropdown nur Rohstoff-Lieferanten
Im Produkt-/INCI-Formular zeigt das „Lieferanten"-Dropdown jetzt nur Lieferanten
der Kategorie „Kosmetikrohstoffe" statt aller Lieferanten (Live: 30 → 15). Filter
über whereHas supplierCategories per Kategoriename (stabiles Merkmal, keine
hartkodierte id). Test ergänzt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-28 09:13:42 +00:00

32 lines
1.4 KiB
PHP

<?php
use App\Models\Ingredient;
use App\Models\Supplier;
use App\Models\SupplierCategory;
use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
uses(TestCase::class, RefreshDatabase::class);
test('AP-49: INCI-Lieferanten-Dropdown zeigt nur Rohstoff-Lieferanten', function () {
$user = User::query()->create(['email' => uniqid('sf_', true).'@test.example', 'password' => bcrypt('password')]);
$user->forceFill(['admin' => 7, 'confirmed' => true, 'active' => true, 'wizard' => 100, 'blocked' => false])->save();
$rawCat = SupplierCategory::query()->create(['name' => 'Kosmetikrohstoffe', 'pos' => 0]);
$packCat = SupplierCategory::query()->create(['name' => 'Versandverpackungen', 'pos' => 1]);
$raw = Supplier::factory()->create(['name' => 'AP49-RohstoffLieferant', 'active' => true]);
$raw->supplierCategories()->attach($rawCat->id);
$pack = Supplier::factory()->create(['name' => 'AP49-VerpackungsLieferant', 'active' => true]);
$pack->supplierCategories()->attach($packCat->id);
$ing = Ingredient::query()->create(['name' => 'AP49-INCI', 'active' => true, 'pos' => 0]);
$this->actingAs($user->fresh(), 'user');
$this->get(route('admin_product_ingredient_edit', $ing->id))
->assertSuccessful()
->assertSee('AP49-RohstoffLieferant')
->assertDontSee('AP49-VerpackungsLieferant');
});