makeShopEnv()); describe('Dashboard-Card Einmalprodukte', function () { it('zeigt die Card mit Link zum eigenen Abo', function () { // Domain-aware Route wird im Test-Kontext nicht geladen -> route() mocken URL::shouldReceive('route')->andReturnUsing( fn ($name, $params = [], $absolute = true) => '/user/abos/detail/'.($params['view'] ?? '').'/'.($params['id'] ?? '') ); $abo = makeMeAbo(); $html = view('dashboard._abo_onetime', ['oneTimeAbo' => $abo])->render(); expect($html)->toContain(__('abo.onetime_card_hl')) ->and($html)->toContain(__('abo.add_onetime_product')) ->and($html)->toContain('/user/abos/detail/me/'.$abo->id); }); it('rendert nichts, wenn kein Abo übergeben wird', function () { $html = view('dashboard._abo_onetime', ['oneTimeAbo' => null])->render(); expect(trim($html))->toBe(''); }); }); describe('Reminder-Mail-Vorschau Command', function () { it('rendert die Reminder-Mail als HTML ohne Versand', function () { Storage::fake('public'); Mail::fake(); $abo = makeMeAbo(); $this->artisan('abo:preview-reminder', ['abo' => $abo->id])->assertExitCode(0); Storage::disk('public')->assertExists('preview/abo-reminder-'.$abo->id.'.html'); $html = Storage::disk('public')->get('preview/abo-reminder-'.$abo->id.'.html'); expect($html)->toContain('/user/abos/detail/me/'.$abo->id); Mail::assertNothingSent(); }); it('versendet zusätzlich bei --send (Mailpit-Test)', function () { Storage::fake('public'); Mail::fake(); $abo = makeMeAbo(); $this->artisan('abo:preview-reminder', ['abo' => $abo->id, '--send' => 'test@example.com']) ->assertExitCode(0); Mail::assertSent(MailAboExecutionReminder::class, 1); }); it('lehnt ein unbekanntes Abo ab', function () { $this->artisan('abo:preview-reminder', ['abo' => 999999])->assertExitCode(1); }); });