create([ 'email' => uniqid('urlfield_', true).'@test.example', 'password' => bcrypt('password'), ]); $user->forceFill([ 'admin' => $adminLevel, 'confirmed' => true, 'active' => true, 'wizard' => 100, 'blocked' => false, ])->save(); return $user->fresh(); } function urlTestCountry(): Country { return Country::query()->firstOrCreate( ['code' => 'DE'], [ 'phone' => '00', 'en' => 'Germany', 'de' => 'Deutschland', 'es' => 'Germany', 'fr' => 'Germany', 'it' => 'Germany', 'ru' => 'Germany', 'active' => true, ] ); } test('supplier speichert URL mit Parametern (B1/B2)', function () { $country = urlTestCountry(); $user = urlTestUser(7); $this->actingAs($user, 'user'); $this->post(route('admin.inventory.suppliers.store'), [ 'name' => 'Kartons-auf-Mass', 'country_id' => (string) $country->id, 'url' => configuratorUrl(), 'active' => '1', ])->assertRedirect(route('admin.inventory.suppliers.index')); $supplier = Supplier::query()->where('name', 'Kartons-auf-Mass')->firstOrFail(); expect($supplier->url)->toBe(configuratorUrl()); }); test('supplier ohne URL bleibt speicherbar', function () { $country = urlTestCountry(); $user = urlTestUser(7); $this->actingAs($user, 'user'); $this->post(route('admin.inventory.suppliers.store'), [ 'name' => 'Ohne-URL', 'country_id' => (string) $country->id, 'active' => '1', ])->assertRedirect(route('admin.inventory.suppliers.index')); expect(Supplier::query()->where('name', 'Ohne-URL')->value('url'))->toBeNull(); }); test('packaging item speichert URL mit Parametern (B2)', function () { $material = PackagingMaterial::factory()->create(); $user = urlTestUser(7); $this->actingAs($user, 'user'); $this->post(route('admin.inventory.packaging-items.store'), [ 'packaging_material_id' => (string) $material->id, 'name' => 'Versandkarton Konfigurator', 'category' => 'shipping', 'url' => configuratorUrl(), 'active' => '1', ])->assertRedirect(route('admin.inventory.packaging-items.index', ['category' => 'shipping'])); $item = PackagingItem::query()->where('name', 'Versandkarton Konfigurator')->firstOrFail(); expect($item->url)->toBe(configuratorUrl()); });