create(['email' => uniqid('smr_', true).'@test.example', 'password' => bcrypt('password')]); $user->forceFill(['admin' => 9, 'confirmed' => true, 'active' => true, 'wizard' => 100, 'blocked' => false])->save(); return $user->fresh(); } test('AP-48: seed liefert getrennte gründe für eingang und ausgang', function () { expect(StockMovementReason::query()->where('direction', 'in')->count())->toBeGreaterThan(0) ->and(StockMovementReason::query()->where('direction', 'out')->count())->toBeGreaterThan(0) // „Testervergabe" ist ein Ausgangs-, kein Eingangsgrund ->and(StockMovementReason::query()->where('direction', 'out')->where('label', 'Testervergabe')->exists())->toBeTrue() ->and(StockMovementReason::query()->where('direction', 'in')->where('label', 'Testervergabe')->exists())->toBeFalse(); }); test('AP-48: grund kann mit richtung angelegt werden', function () { $this->actingAs(smrAdmin(), 'user'); $this->post(route('admin.inventory.stock-movement-reasons.store'), [ 'label' => 'AP48-Sonderentnahme', 'direction' => 'out', 'active' => '1', 'pos' => '3', ])->assertRedirect(route('admin.inventory.general')); $reason = StockMovementReason::query()->where('label', 'AP48-Sonderentnahme')->firstOrFail(); expect($reason->direction)->toBe('out')->and($reason->active)->toBeTrue(); }); test('AP-48: produktbestand-maske liefert die gründe je richtung', function () { $this->actingAs(smrAdmin(), 'user'); StockMovementReason::query()->create(['label' => 'AP48-NurEingang', 'direction' => 'in', 'active' => true, 'pos' => 9]); $this->get(route('admin.inventory.product-stock.index')) ->assertSuccessful() ->assertSee('AP48-NurEingang'); }); test('AP-48: grund ist immer löschbar', function () { $this->actingAs(smrAdmin(), 'user'); $reason = StockMovementReason::query()->create(['label' => 'AP48-Weg', 'direction' => 'in', 'active' => true, 'pos' => 9]); $this->delete(route('admin.inventory.stock-movement-reasons.destroy', $reason)) ->assertRedirect(route('admin.inventory.general')); expect(StockMovementReason::query()->find($reason->id))->toBeNull(); });