Umsetzung der Warenwirtschafts-/Produktmanagement-Erweiterung gemaess Entwicklungsplan V4.0: - AP-00: Regressionsbasis fuer 5.1-Features (ProductPhase51Test) - AP-01: URL-Bugfixes B1/B2 (suppliers/packaging-items, breitere url-Spalten) - AP-04/04.1: iPad-taugliche, vereinheitlichte Tabellen-Aktionen - AP-05: Einstellungen "Allgemein" mit UST-Saetzen (tax_rates) und Lieferzeit-Vorlagen (delivery_times, inkl. Tage-Feld) - AP-06: Lieferanten um Bestellweg, Bestell-Mail/-URL und Lieferzeit erweitert - AP-07/07.1: INCI um Lieferanten-Mehrfachwahl, UST und Lieferzeit erweitert; Lieferanten-Detailansicht im Modal mit pflegbaren INCI-/Verpackungslisten - AP-08: Einkauf um UST-Snapshot, Netto/Brutto-Automatik und Duplizieren erweitert Entwicklungsplan aktualisiert: alle Klaerungspunkte (§5) vom Kunden beantwortet und in die jeweiligen APs eingearbeitet (AP-02/03/09/13/15), neues AP-18 (Hinweise-Doku unter Einstellungen) ergaenzt. Naechster Schritt eindeutig markiert: AP-09 (Produktion auf Hersteller-Rezeptur, kein Fallback, Warnung).
100 lines
3 KiB
PHP
100 lines
3 KiB
PHP
<?php
|
|
|
|
use App\Models\Country;
|
|
use App\Models\PackagingItem;
|
|
use App\Models\PackagingMaterial;
|
|
use App\Models\Supplier;
|
|
use App\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class, RefreshDatabase::class);
|
|
|
|
/**
|
|
* Konfigurator-URL mit kodierten Parametern (Versandverpackung), siehe docs/Todos.md.
|
|
*/
|
|
function configuratorUrl(): string
|
|
{
|
|
return 'https://www.kartonsaufmass.de/bestellen?bom_configuration=%7B%2522length%2522:125,%2522width%2522:125,%2522height%2522:30,%2522amount%2522:100%7D';
|
|
}
|
|
|
|
function urlTestUser(int $adminLevel): User
|
|
{
|
|
$user = User::query()->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());
|
|
});
|